void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int k; rd(k);

  int n=1;
  while((1<<n)<=k) n++;
  struct E{int u, v, w;}
  E[] edges;
  int w=0;
  for(int i=1; i<n; i++){
    edges~=E(i, i+1, 0);
    edges~=E(i, i+1, 1<<(n-i-1));
    w+=(1<<(n-i-1));
  }

  if(w<(k-1)){
    w=0;
    for(int i=2; i<=n; i++){
      if(k&(1<<(n-i))){
        edges~=E(1, i, (1<<(n-1))+w);
        w+=(1<<(n-i));
      }
    }
  }

  writeln(n, " ", edges.length);
  foreach(e; edges){
    writeln(e.u, " ", e.v, " ", e.w);
  }
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}
