#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

struct edge {
    ll src, dst, cost;
    edge() {}
    edge(ll a, ll b, ll c) : src(a), dst(b), cost(c) {}
};

int main() {
    ll L, r = 1;
    ll N = 0, M;
    vector<edge> G;

    cin >> L;

    while (r <= L) {
        r *= 2;
        N++;
    }
    for (ll i = 1; i < N; i++) {
        G.push_back( edge(i, i+1, 0) );
        G.push_back( edge(i, i+1, (1<<(i-1))) );
    }

    ll remain = L - (1<<(N-1));

    for (ll i = N-1; i >= 1; i--) {
        if (!remain) { break; }

        if ( remain >= (1 << (i-1)) ) {
            G.push_back( edge(i, N, L-remain) );
            remain -= (1 << (i-1));
        }
    }

    M = G.size();

    cout << N << " " << M << endl;

    for (auto &e: G) {
        cout << e.src << " " << e.dst << " " << e.cost << endl;
    }

    return 0;
}