function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var l = o.a()-1;
  var x = 1;
  var ans = [];
  for(var i = 1; i < 20; i++)ans[i] = [i,i+1,0];
  var j = 20, u = 1, v = 19;
  for(i = 1; i <= l; i <<= 1){
    if(i*2 > l)ans[j] = [u,20,i];
    else if(l & i){ans[j] = [u,u+1,i];j++;u++;}
    else {ans[j] = [v,v+1,i];j++;v--;}
  }
  ans[0] = [20,j];
  return ans.map(a=>a.join(" ")).join("\n");
}