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

  int k; rd(k);
  int[] digit;
  while(k){
    digit~=k&1;
    k/=2;
  }
  reverse(digit);

  struct E{int u, v, w;}
  E[] edges;
  int n=1; k=1;
  foreach(d; digit[1..$]){
    foreach(ref e; edges) e.w*=2;
    edges~=E(n, n+1, 0);
    edges~=E(n, n+1, 1);
    k*=2;
    if(d){
      edges~=E(1, n+1, k);
      k++;
    }
    n++;
  }

  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));
}