object Main extends App {
	import scala.math._

	val L = scala.io.StdIn.readInt
	var r = (log(L)/log(2)).toInt

	var edge = List[(Int, Int, Long)]()

	for(i<-1 to r){
		edge = (i, i+1, 0L) :: (i, i+1, pow(2L, i).toLong) :: edge
	}

	for(t <- r to 1 by -1){
		var Lp = L

		while(Lp - pow(2L, t-1).toLong > pow(2, r).toLong){
			edge = (t, r+1, Lp - pow(2L, t-1).toLong)::edge
			Lp = Lp - pow(2, t-1).toInt
		}
	}

	println((r+1) + " " + edge.size)

	for(x<-edge){
		x match {
			case (a, b, c) => println(a + " " + b + " " + c) 
		}
	}

}