#pragma GCC optimize("O3") #define _USE_MATH_DEFINES #include #define BOOST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define FOR(a, b, c) for(int a = b; a < c; ++a) #define PB push_back #define MP make_pair #define INF (int)1e9+7 #define LLINF 2e18+7 #define ALL(a) a.begin(), a.end() #define SIZE(a) (int)a.size() typedef unsigned long long ULL; typedef long long LL; typedef long double LD; using namespace std; //#define DEBUG int main() { #ifndef DEBUG BOOST; #endif LL n; cin >> n; vector row(101); row[50] = 1; cout << 1000 * 101 << "\n"; FOR(i, 0, 1000) { FOR(j, 0, 101) { if(j != 50) cout << 2 * i << " " << j << " " << 0 << "\n"; else cout << 2 * i << " " << j << " " << 1 << "\n"; } } LL pow3 = 1; int days = 0; while(pow3 < n) { days++; pow3 *= 3; vector newRow = row; FOR(i, 0, 101) { if(i) newRow[i] += row[i - 1]; if(i + 1 < 101) newRow[i] += row[i + 1]; } row = newRow; } vector > res; map > > gowno; FOR(i, 0, 101) { FOR(j, 0, 1000) if (row[i] > 0) gowno[-row[i]].push_back({2 * j, i}); } for (auto z : gowno) { auto tmp = min(n / -z.first, (LL)z.second.size()); FOR(i, 0, tmp) res.push_back(z.second[i]); n += z.first * tmp; } assert(!n); cout << res.size() << " " << days << "\n"; for (auto& z : res) { cout << z.first << " " << z.second << "\n"; } return 0; }