#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int L;
    cin >> L;
    int l = L;
    vector<int> digit;
    while (l) {
        digit.push_back(l%2);
        l >>= 1;
    }
    int size = digit.size();
    printf("%d ", size);
    vector<pair<pair<int, int>, int> > edges;
    int length = 1;
    for (int i = 1; i < size; i++) {
        edges.push_back(make_pair(make_pair(i, i+1), 0));
        edges.push_back(make_pair(make_pair(i, i+1), length));
        length *= 2;
    }
    for (int i = 1; i < size; i++) {
        if (digit[size-i-1] == 1) {
            edges.push_back(make_pair(make_pair(size-i, size), length));
            length += 1<<(size-i-1);
        }
    }
    printf("%d\n", (int)edges.size());
    for (const auto &edge : edges) {
        printf("%d %d %d\n", edge.first.first, edge.first.second, edge.second);
    }
    return 0;
}