#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int L; cin >> L;
	
	int r = 0;
	while (L >= (1 << r)) ++r;
	--r;

	vector<pair<Pii, int>> edges;
	for (int i = 0; i < r; ++i) {
		edges.emplace_back(make_pair(i + 1, i + 2), 0);
		edges.emplace_back(make_pair(i + 1, i + 2), (1 << i));
	}

	int R = (1 << r);
	for (int i = r - 1; i >= 0; --i) {
		int s = L - (1 << i);
		if (s >= R) {
			edges.emplace_back(make_pair(i + 1, r + 1), s);
			L = s;
		}
	}

	cout << r + 1 << " " << edges.size() << "\n";
	for (const auto& e : edges) {
		cout << e.first.first << " " << e.first.second << " " << e.second << "\n";
	}

	return 0;
}