// Marcin Knapik Uwr1 // The codes may contain some pastes from: https://github.com/ShahjalalShohag/code-library #pragma GCC optimize "O3" #include using namespace std; #define sz(s) (int)s.size() #define f first #define s second #define pb push_back #define all(s) s.begin(), s.end() #define vi vector #define vvi vector #define ll long long #define ull unsigned ll #define vll vector #define vvll vector #define ii pair #define pll pair #define vii vector #define vvii vector #define viiii vector > const ll BIG_INF = 1e18; const int mod = 998244353; const int INF = 1e9 + 7; const int N = 1e6 + 7; // const int T = 1 << 20; #define ld long double template ostream & operator << (ostream&os, const pair & para) { os << para.first << ' ' << para.second; return os; } template ostream & operator << (ostream&os, const vector & vec){ for(int i = 0; i < sz(vec); i++) os << vec[i] << (i == sz(vec) - 1 ? "" : " "); return os; } template istream & operator >> (istream&is, vector & vec){ for(T & el : vec) is >> el; return is; } template istream & operator >> (istream&os, pair & para) { os >> para.first >> para.second; return os; } template void setmax(T & a, T b) {a = (a >= b ? a : b);} template void setmin(T & a, T b) {a = (a <= b ? a : b);} mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define losuj(a, b) uniform_int_distribution(a, b)(rng) #define rep(i, n) for(int i = 0; i < n; i++) #define per(i, n) for(int i = n - 1; i >= 0; i--) ll n; const int BLOK = 99; const int ILE = 100; const int MAXI = 10000; ll maxi(vll & blok){ ll ret = 0; for(auto & u : blok){ ret = max(ret, u); } return ret; } vll nast(vll blok){ vll ret = vll(sz(blok)); for(int i = 0; i < sz(blok); i++) for(int j = -1; j <= 1; j++) if((i + j) > 0 and (i + j) < sz(blok)) ret[i] += blok[i + j]; return ret; } void solve(){ cin >> n; vll blok(BLOK); blok[BLOK / 2] = 1; int kroki = 0; while(maxi(blok) < n){ blok = nast(blok); kroki++; } set< pair > secik; vii changed; for(int i = 0; i < ILE; i++){ int row = i * 2; for(int col = 0; col < sz(blok); col++){ secik.insert({blok[col], {row, col}}); changed.pb({row, col}); // if(blok[col] > 0){ // cout << "JEST JEDYNKA " << endl; // cout << blok[col] << ' ' << col << endl; // } } } // cout << sz(secik) << endl; // exit(0); vii harvested; while(n){ auto it = secik.upper_bound(make_pair(n, make_pair(-INF, -INF))); // assert(it != secik.begin()); if(it == secik.end() or (*it).f > n) it = prev(it); harvested.pb((*it).s); n -= (*it).f; // cout << "DEBUG: " << (*it).f << endl; // exit(0); secik.erase(it); } assert(sz(harvested) <= MAXI); assert(sz(changed) <= MAXI); assert(n == 0); cout << sz(changed) << '\n'; for(auto & u : changed) cout << u.f << ' ' << u.s << ' ' << (u.s == (BLOK / 2) ? 1 : 0) << '\n'; cout << sz(harvested) << ' ' << kroki << '\n'; for(auto & u : harvested) cout << u.f << ' ' << u.s << '\n'; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); int test = 1; // cin >> test; for(int i = 1; i <= test; i++) solve(); return 0; }