#include<iostream>
#include<vector>

using namespace std;

#define f first
#define s second

typedef pair<int,int> point;

const bool check = false;

int start = 0;
int cut = 0;
int noharvested = 0;
vector<point> harvested;
vector<point> tabacco;
vector<point> grass;


bool inBounds(point p) {
	return p.f >= -1000000 && p.f <= 1000000 && p.s >= -1000000 && p.s <= 1000000;
}

void removeflowers() {
	cut++;
	if (check && cut > 200000)
		cerr << "too many cut\n";
}

void plantTabacco(point p) {
	if (check && !inBounds(p))
		cerr << p.f << " " << p.s << " not in bounds\n";
	removeflowers();
	tabacco.push_back(p);
}

void cuttograss(point p) {
	if (check && !inBounds(p))
		cerr << p.f << " " << p.s << " not in bounds\n";
	removeflowers();
	grass.push_back(p);
}

void harvest(point p) {
	if (check && !inBounds(p))
		cerr << p.f << " " << p.s << " not in bounds\n";
	harvested.push_back(p);
	noharvested++;
	if (check && noharvested > 10000) {
		cerr << "too much harvested\n";
	}
}

void makeLine(int power) {
	point akt = {start, 0};
	plantTabacco(akt);
	for (int i = 0; i < 50; i ++) {
		akt.f++;
		cuttograss(akt);
		akt.s++;
		if (i < power) {
			akt.f--;
			cuttograss(akt);
			akt.f++;
		}
		cuttograss(akt);
	}
	harvest(akt);
	start+=4;
}

int main() {
	long long n;
	cin >> n;
	long long power = 50;
	while (n > 0) {
		if (((long long)1 << power) <= n) {
			n -= ((long long)1 << power);
			makeLine(power);
		}
		else {
			power --;
		}
	}
	cout << cut << "\n";
	for (point p : grass)
		cout << p.f << " " << p.s << " 0\n";
	for (point p : tabacco)
		cout << p.f << " " << p.s << " 1\n";
	cout << noharvested << " 100\n";
	for (point p : harvested)
		cout << p.f << " " << p.s << "\n";
}