#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define SIZE(a) int((a).size();
const int INF=INT_MAX;
struct edge{ll from,to,length;};
int main(){
  ll l;cin>>l;
  ll copy=l,r=0,n,m;
  while(copy>1){
    copy/=2;r++;
  }
  ll _copy=l;
  l-=pow(2,r);
  n=r+1;m=2*r;
  ll t=r;
  vll tt(0);
  while(l>0){
    if(l>=pow(2,t-1)){
      l-=pow(2,t-1);
      tt.push_back(t);
    }
    t--;
  }
  m+=tt.size();
  vector<edge> g(m);
  rep(i,0,r){
    g[i*2].from=i+1;g[i*2].to=i+2;g[i*2].length=0;
    g[i*2+1].from=i+1;g[i*2+1].to=i+2;g[i*2+1].length=pow(2,i);
  }
  rep(i,0,tt.size()){
    g[2*r+i].from=tt[i];g[2*r+i].to=n;g[2*r+i].length=_copy-pow(2,tt[i]-1);
    _copy-=pow(2,tt[i]-1);
  }
  cout<<n<<" "<<m<<endl;
  rep(i,0,m){
    cout<<g[i].from<<" "<<g[i].to<<" "<<g[i].length<<endl;
  }
}
