import java.lang.Math.*

data class Edge(val from: Int, val to: Int, val cost: Int)

fun log2(x: Int) = (log(x.toDouble()) / log(2.0) + 1e-10).toInt()

fun main(args: Array<String>) {
  val l = readLine()!!.toInt()
  var edges = mutableListOf<Edge>()
  var v = 1
  var e = 0
  var t = 1
  var b = log2(l) - 1
  while (t < l) {
    for (i in 0 until edges.size) {
      val es = edges[i]
      edges[i] = Edge(es.from, es.to, es.cost * 2)
    }
    edges.add(Edge(v, v + 1, 0))
    edges.add(Edge(v, v + 1, 1))
    v++
    e += 2
    t *= 2
    if ((l shr b) % 2 == 1) {
      edges.add(Edge(1, v, t))
      e++
      t++
    }
    b--
  }
  println("${v} ${e}")
  edges.forEach { println("${it.from} ${it.to} ${it.cost}") }
}
