#include using namespace std; int f(int n) { if (n < 0) return 0; int s = round(sqrt(n)); return s * s == n; } int main() { int n; cin >> n; if (n == 2) { cout << "1\n1 2 1\n1 1" << endl; return 0; } int a[55], b[55], x = 1, u[205] = {0}; u[x] = 1; for (int i = 3; i <= n; i++) { bool ok = false; for (int p = 1; p <= 200; p++) { if (u[p]) continue; for (int q = 1; q <= 200; q++) { if (u[q] || p == q) continue; if (!(f(p) || f(q + x))) continue; if (!(f(q) || f(p + x))) continue; bool ok_ = true; for (int j = 3; j < i; j++) { if (f(p + a[j]) || f(q + b[j]) || f(p + x + b[j]) || f(q + x + a[j])) continue; ok_ = false; break; } if (ok_) { a[i] = p; b[i] = q; u[p] = u[q] = 1; ok = true; break; } } if (ok) break; } } cout << 2 * n - 3 << "\n1 2 " << x << endl; for (int i = 3; i <= n; i++) { cout << "1 " << i << " " << a[i] << "\n2 " << i << " " << b[i] << endl; } for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i == 1 && j == 2) { cout << "1 1" << endl; } else if (i == 1) { if (f(a[j])) cout << "1 " << 2 * j - 4 << endl; else cout << "2 1 " << 2 * j - 3 << endl; } else if (i == 2) { if (f(b[j])) cout << "1 " << 2 * j - 3 << endl; else cout << "2 1 " << 2 * j - 4 << endl; } else { if (f(a[i] + a[j])) cout << "2 " << 2 * i - 4 << " " << 2 * j - 4 << endl; else if (f(b[i] + b[j])) cout << "2 " << 2 * i - 3 << " " << 2 * j - 3 << endl; else if (f(a[i] + x + b[j])) cout << "3 " << 2 * i - 4 << " 1 " << 2 * j - 3 << endl; else cout << "3 " << 2 * i - 3 << " 1 " << 2 * j - 4 << endl; } } } return 0; }