#include #include using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define all(x) begin(x), end(x) template bool chmin(T& x, T y) { return x > y ? (x = y, true) : false; } template bool chmax(T& x, T y) { return x < y ? (x = y, true) : false; } void solve() { int n; cin >> n; if (n == 2) { cout << "1\n1 2 1\n1 1\n"; return; } if (n == 3) { cout << "3\n1 2 1\n1 3 1\n2 3 1\n"; cout << "1 1\n1 2\n1 3\n"; return; } if (n == 4) { cout << "4\n1 2 9\n2 3 16\n3 4 9\n4 1 16\n"; cout << "1 1\n2 1 2\n1 4\n"; cout << "1 2\n2 2 3\n1 3\n"; return; } vector> g(n, vector(n, -1)); cout << n * 2 - 3 << '\n'; { int cnt = 0; rep(i, 0, n) { if (i + 1 < n) { g[i][i + 1] = cnt; g[i + 1][i] = cnt; cnt++; cout << i + 1 << ' ' << i + 2 << ' ' << 1 << '\n'; } if (i + 2 < n) { g[i][i + 2] = cnt; g[i + 2][i] = cnt; cnt++; cout << i + 1 << ' ' << i + 3 << ' ' << 1 << '\n'; } } } vector p2 = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100}; rep(st, 0, n) rep(ed, st + 1, n) { vector v; if (ed - st <= 2) { v.push_back(g[st][ed]); } else if (ed - st == 3) { if (st == 0) { v.push_back(g[0][1]); v.push_back(g[1][2]); v.push_back(g[2][4]); v.push_back(g[4][3]); } else { v.push_back(g[st][st - 1]); v.push_back(g[st - 1][st + 1]); v.push_back(g[st + 1][st + 2]); v.push_back(g[st + 2][st + 3]); } } else { int cd = *prev(upper_bound(all(p2), ed - st)); int m2 = (ed - st) - cd; int nw = st; rep(i, 0, m2) { v.push_back(g[nw][nw + 2]); nw += 2; } rep(i, m2, cd) { v.push_back(g[nw][nw + 1]); nw++; } assert(nw == ed); } assert(binary_search(all(p2), v.size())); // cout << st << " -> " << ed << " : "; cout << v.size(); for (int x : v) cout << ' ' << x + 1; cout << '\n'; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); int t = 1; // cin >> t; while (t--) solve(); }