output_description: In the first line, print N and M, the number of the vertices and edges in your
  graph. In the i-th of the following M lines, print three integers u_i,v_i and
  w_i, representing the starting vertex, the ending vertex and the length of the
  i-th edge. If there are multiple solutions, any of them will be accepted.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      L
attempt: def getN():
      return int(input())
  
  
  def getNM():
      return map(int, input().split())
  
  
  def getList():
      return list(map(int, input().split()))
  
  
  def getArray(intn):
      return [int(input()) for i in range(intn)]
  
  
  def input():
      return sys.stdin.readline().rstrip()
  
  
  def rand_N(ran1, ran2):
      return random.randint(ran1, ran2)
  
  
  def rand_List(ran1, ran2, rantime):
      return [random.randint(ran1, ran2) for i in range(rantime)]
  
  
  def rand_ints_nodup(ran1, ran2, rantime):
      ns = []
      while len(ns) < rantime:
          n = random.randint(ran1, ran2)
          if not n in ns:
              ns.append(n)
      return sorted(ns)
  
  
  def rand_query(ran1, ran2, rantime):
      r_query = []
      while len(r_query) < rantime:
          n_q = rand_ints_nodup(ran1, ran2, 2)
          if not n_q in r_query:
              r_query.append(n_q)
      return sorted(r_query)
  
  
  from collections import defaultdict, deque, Counter
  from sys import exit
  from decimal import *
  import heapq
  from math import sqrt, pi
  from fractions import gcd
  import random
  import string
  import copy
  from itertools import combinations, permutations, product
  from operator import mul, itemgetter
  from functools import reduce
  from bisect import bisect_left, bisect_right
  
  import sys
  
  sys.setrecursionlimit(1000000000)
  mod = 10**9 + 7
  
  #############
  # Main Code #
  #############
  
  L = int(input())
  
  Lstr = bin(L)[2:]
  
  N = len(Lstr)
  M = (N - 1) * 2 + (Lstr.count("1") - 1)
  
  print(N, M)
  c = 1
  for i in range(1, N):
      print(i, i + 1, c)
      print(i, i + 1, 0)
      c *= 2
  
  c = 2 ** (N - 1)
  for i, v in enumerate(Lstr[::-1]):
      if i == N - 1:
          continue
      if v == "1":
          print(i + 1, N, c)
          c += 2**i
  
problem_description: Statement
  
  You are given an integer L. Construct a directed graph that satisfies the
  conditions below. The graph may contain multiple edges between the same pair
  of vertices. It can be proved that such a graph always exists.
  
    * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.
    * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).
    * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.
    * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.
  
  Here, the length of a path is the sum of the lengths of the edges contained in
  that path, and two paths are considered different when the sets of the edges
  contained in those paths are different.
samples: [{"input": "4", "output": "8 10\n    1 2 0\n    2 3 0\n    3 4 0\n    1 5 0\n    2 6 0\n    3 7 0\n    4 8 0\n    5 6 1\n    6 7 1\n    7 8 1\n    \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n  * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n  * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n  * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n  * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n    1 2 0\n    2 3 1\n    3 4 0\n    4 5 0\n    2 4 0\n    1 3 3\n    3 5 1"}]