#include <bits/stdc++.h>
using namespace std;

queue<pair< pair<int, int>, int> > que;

int main(){
    int l;
    cin >> l;

    int p = 1;
    int n = 1;
    while(p*2 <= l){
        p *= 2;
        n += 1;
    }
    int ans_n = n;

    int xx = 1;
    for(int i = n-1;i >= 1;i--){
        que.push(make_pair(make_pair(i, i+1), 0));
        que.push(make_pair(make_pair(i, i+1), xx));
        xx *= 2;
    }

    l = l ^ (1 << (n-1));

    int r = n;
    int w = p;
    int x = 1;

    while(l > 0){
        if(l & 1){
            que.push(make_pair(make_pair(1, r), w));
            w += x;
        }
        x *= 2;
        l >>= 1;
        r--;
    }

    cout << ans_n << " " << que.size() << endl;
    while(!que.empty()){
        pair<pair<int, int> , int> p = que.front();
        cout << p.first.first << " " << p.first.second << " "<< p.second << endl;
        que.pop();
    }

    return 0;
}
