#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int f (int x) {
	int r = 0;
	while (r < 19 and (1 << (r + 1)) <= x) r++;
	return r;
}

int main() {
	int l;
	cin >> l;
	const int r = f(l);
	
	vector<pair<P, int>> edge;
	for (int v = 0; v < r; v++) {
		edge.emplace_back(P(v, v + 1), 0);
		edge.emplace_back(P(v, v + 1),(1 << v));
	}
	
	for (int v = r - 1; v >= 0; v--) {
		int val = l - (1 << v);
		if (val >= (1 << r)) {
			edge.emplace_back(P(v, r), val);
			l = val;
		}
	}
	
	cout << r + 1 << ' ' << edge.size() << '\n';
	for (const auto &e : edge) {
		int v, u; tie(v, u) = e.first;
		cout << v + 1 << ' ' << u + 1 << ' ' << e.second << '\n';
	}
	
	return 0;
}