#include using namespace std; using ll = long long; //a ^ b mod m //aがlong longじゃないと危険 template T modpow(T a, U b, V m) { T res = 1; a %= m; while (b) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res; } // miller-Rabin 素数判定(O(log(N))) bool isprime(long long N) { if (N <= 1) return 0; if (N == 2) return 1; if (N % 2 == 0) return 0; vector a = {2, 325, 9375, 28178, 450775, 9780504, 1795265022}; long long s = 0, d = N - 1; while (d % 2 == 0) { s++; d >>= 1; } for (auto a : a) { if (a % N == 0) return 1; long long t, x = modpow<__int128_t>(a, d, N); if (x != 1) { for (t = 0; t < s; t++) { if (x == N - 1) break; x = __int128_t(x) * x % N; } if (t == s) return 0; } } return 1; } template T gcd(T a, T b) { if (a > b) swap(a, b); while (a != 0){ b %= a; swap(a, b); } return b; } // Pollard のロー法 long long pollard(long long N) { if (N % 2 == 0) return 2; if (isprime(N)) return N; auto f = [&](long long x) -> long long { return (__int128_t(x) * x + 1) % N; }; long long step = 0; while (1) { ++step; long long x = step, y = f(x); while (1) { long long p = gcd(y - x + N, N); if (p == 0 || p == N) break; if (p != 1) return p; x = f(x); y = f(f(y)); } } } //素因数分解(O(N^1/4)log(N)?) vector pfact(long long N) { if (N == 1) return {}; long long p = pollard(N); if (p == N) return {p}; vector left = pfact(p); vector right = pfact(N / p); left.insert(left.end(), right.begin(), right.end()); sort(left.begin(), left.end()); return left; } vector get_factor(long long N) { if (N == 1) return {1}; vector prime_factors = pfact(N); map factor_count; for (long long p : prime_factors) { factor_count[p]++; } vector divisors = {1}; for (auto& [prime, count] : factor_count) { vector new_divisors; for (long long div : divisors) { long long power = 1; for (int i = 0; i <= count; i++) { new_divisors.push_back(div * power); power *= prime; } } divisors = new_divisors; } sort(divisors.begin(), divisors.end()); return divisors; } ll power(ll x, int e){ ll t = 1; for (int i = 0; i < e; i++) t *= x; return t; } vector> ans; void solve(ll n, int e) { ll l = 1, r = 1; ll t = 1; while (power(r, e) <= n){ if (t == n){ ans.push_back({e, l, r}); } if (t <= n) { r++; t += power(r, e); } else { t -= power(l, e); l++; } } return; } __int128_t square_sum(ll x){ return (__int128_t)x * (x + 1) * (2 * x + 1) / 6; } void solve2(ll n){ vector factor = get_factor(n * 6); for (ll d : factor){ auto check = [&](ll mid)->bool { return square_sum(mid + d - 1) - square_sum(mid - 1) <= n; }; ll ok = 1, ng = 1<<30; if (square_sum(ok + d - 1) - square_sum(ok - 1) > n){ continue; } while (abs(ok - ng) > 1){ ll mid = (ok + ng) / 2; if (check(mid)) ok = mid; else ng = mid; } if (square_sum(ok + d - 1) - square_sum(ok - 1) == n){ ans.push_back({2, ok, ok + d - 1}); } } } int main(){ ll n; cin >> n; assert(1 <= n && n <= 1000000000000000000); solve2(n); for (int i = 3; i < 60; i++){ solve(n, i); } sort(ans.begin(), ans.end()); cout << ans.size() << "\n"; for (auto [e, l, r] : ans){ cout << e << " " << l << " " << r << endl; } }