#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; //#define int long long typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; constexpr ll mod = 1000000007; const ll INF = mod * mod; typedef pairP; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i=0;i--) #define Rep(i,sta,n) for(int i=sta;i=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) #define all(v) (v).begin(),(v).end() typedef pair LP; typedef double ld; typedef pair LDP; const ld eps = 1e-12; const ld pi = acosl(-1.0); ll mod_pow(ll x, ll n, ll m) { ll res = 1; while (n) { if (n & 1)res = res * x % m; x = x * x % m; n >>= 1; } return res; } struct modint { ll n; modint() :n(0) { ; } modint(ll m) :n(m) { if (n >= mod)n %= mod; else if (n < 0)n = (n % mod + mod) % mod; } operator int() { return n; } }; bool operator==(modint a, modint b) { return a.n == b.n; } modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; } modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; } modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; } modint operator+(modint a, modint b) { return a += b; } modint operator-(modint a, modint b) { return a -= b; } modint operator*(modint a, modint b) { return a *= b; } modint operator^(modint a, ll n) { if (n == 0)return modint(1); modint res = (a * a) ^ (n / 2); if (n % 2)res = res * a; return res; } ll inv(ll a, ll p) { return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p); } modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); } const int max_n = 1 << 18; modint fact[max_n], factinv[max_n]; void init_f() { fact[0] = modint(1); for (int i = 0; i < max_n - 1; i++) { fact[i + 1] = fact[i] * modint(i + 1); } factinv[max_n - 1] = modint(1) / fact[max_n - 1]; for (int i = max_n - 2; i >= 0; i--) { factinv[i] = factinv[i + 1] * modint(i + 1); } } modint comb(int a, int b) { if (a < 0 || b < 0 || a < b)return 0; return fact[a] * factinv[b] * factinv[a - b]; } LDP operator*(const LDP& a, const LDP& b) { return LDP{ a.first * b.first - a.second * b.second , a.first * b.second + a.second * b.first }; } LDP operator+(const LDP& a, const LDP& b) { return LDP{ a.first + b.first,a.second + b.second }; } LDP operator-(const LDP& a, const LDP& b) { return LDP{ a.first - b.first,a.second - b.second }; } //非再帰 //eps=0.01を忘れずに typedef vector poly; poly dft(poly f, bool inverse = false) { int n = f.size(); int i, j, k; //bit左右反転 for (i = 0, j = 1; j < n - 1; j++) { for (k = n >> 1; k > (i ^= k); k >>= 1); if (i > j)swap(f[i], f[j]); } for (int m = 2; m <= n; m *= 2) { LDP zeta = { cos(2 * pi / (ld)m), sin(2 * pi / (ld)m) }; if (inverse) { zeta = { cos(2 * pi * (m - 1) / (ld)m), sin(2 * pi * (m - 1) / (ld)m) }; } for (i = 0; i < n; i += m) { LDP powzeta = { 1,0 }; for (k = i; k < i + m / 2; k++) { LDP t1 = f[k], t2 = powzeta * f[k + m / 2]; f[k] = t1 + t2; f[k + m / 2] = t1 - t2; powzeta = powzeta * zeta; } } } if (inverse) { for (i = 0; i < n; i++) { f[i].first /= (ld)n; f[i].second /= (ld)n; } } return f; } poly multiply(poly g, poly h) { int n = 1; int sz = g.size() + h.size(); while (n <= sz)n *= 2; while (g.size() < n) { g.push_back({ 0,0 }); } while (h.size() < n) { h.push_back({ 0,0 }); } poly gg = dft(g); poly hh = dft(h); poly ff; rep(i, n) { ff.push_back(gg[i] * hh[i]); } return dft(ff, true); } struct bigint { using vll = vector; constexpr static ll base = 1000000000; constexpr static ll base_digits = 9; vll a; ll sign; bigint() :sign(1) {} bigint(ll v) { *this = v; } bigint(const string& s) { read(s); } void read(const string& s) { sign = 1; a.clear(); int pos = 0; while (pos < s.size() && (s[pos] == '-' || s[pos] == '+')) { if (s[pos] == '-')sign = -sign; pos++; } for (int i = s.size() - 1; i >= pos; i -= base_digits) { ll x = 0; int le = i - base_digits + 1; if (le < pos)le = pos; for (int j = le; j <= i; j++) { x = x * 10 + s[j] - '0'; } a.push_back(x); } trim(); } friend istream& operator>>(istream& stream, bigint& v) { string s; stream >> s; v.read(s); return stream; } friend ostream& operator<<(ostream& stream, const bigint& v) { if (v.sign == -1)stream << '-'; if (v.a.size())stream << v.a.back(); for (int i = (int)v.a.size() - 2; i >= 0; --i) { stream << setw(base_digits) << setfill('0') << v.a[i]; } return stream; } void operator=(ll v) { sign = 1; if (v < 0)sign = -1, v = -v; while (v > 0) { a.push_back(v % base); v /= base; } } void trim() { while (!a.empty() && a.back() == 0)a.pop_back(); if (a.empty())sign = 1; } bigint operator-()const { bigint res = *this; res.sign = -sign; return res; } bigint abs()const { bigint res = *this; res.sign *= res.sign; return res; } bool operator<(const bigint& v)const { if (sign != v.sign)return sign < v.sign; if (a.size() != v.a.size())return a.size() * sign < v.a.size()* v.sign; per(i, (int)a.size()) { if (a[i] != v.a[i])return a[i] * sign < v.a[i] * sign; } return false; } //comparation bool operator>(const bigint& v)const { return v < *this; } bool operator<=(const bigint& v)const { return !(v < *this); } bool operator>=(const bigint& v)const { return !(*this < v); } bool operator==(const bigint& v)const { return !(*this < v) && !(v < *this); } bool operator!=(const bigint& v)const { return *this < v || v < *this; } //calcuration bigint operator+(const bigint& v)const { if (sign == v.sign) { bigint res = v; ll c = 0; int i = 0; while (i < a.size() || i < v.a.size() || c>0) { if (i == res.a.size())res.a.push_back(0); if (i < a.size())res.a[i] += a[i]; c = res.a[i] >= base; if (c)res.a[i] -= base; i++; } return res; } return *this - (-v); } bigint operator-(const bigint& v)const { if (sign == v.sign) { if (abs() >= v.abs()) { bigint res = *this; int c = 0; int i = 0; while (i < v.a.size() || c) { res.a[i] -= c; if (i < v.a.size())res.a[i] -= v.a[i]; c = res.a[i] < 0; if (c)res.a[i] += base; i++; } res.trim(); return res; } return -(v - *this); } return *this + (-v); } static vll convert_base(const vll& a, ll old_digits, ll new_digits) { vll p(max(old_digits, new_digits) + 1); p[0] = 1; for (int i = 1; i < p.size(); i++)p[i] = p[i - 1] * 10; vll res; ll cur = 0; int cur_digits = 0; rep(i, a.size()) { cur += a[i] * p[cur_digits]; cur_digits += old_digits; while (cur_digits >= new_digits) { res.push_back(signed(cur % p[new_digits])); cur /= p[new_digits]; cur_digits -= new_digits; } } res.push_back((signed)cur); while (!res.empty() && res.back())res.pop_back(); return res; } bigint operator*(const bigint& v)const { constexpr static ll nbase = 10000; constexpr static ll nbase_digits = 4; vll a = convert_base(this->a, base_digits, nbase_digits); vll b = convert_base(v.a, base_digits, nbase_digits); if (a.empty())a.push_back(0); if (b.empty())b.push_back(0); poly p(a.size()); rep(i, a.size())p[i] = { a[i],0 }; poly q(b.size()); rep(i, b.size())q[i] = { b[i],0 }; poly r = multiply(p,q); bigint res; res.sign = sign * v.sign; int i = 0;ll c = 0; rep(i, r.size()) { ll cur = (r[i].first+0.01) + c; res.a.push_back(cur % nbase); c = cur / nbase; if (i + 1 == r.size() && c > 0)r.push_back({ 0,0 }); } res.a = convert_base(res.a, nbase_digits, base_digits); res.trim(); return res; } }; typedef vector> mat; typedef vector vec; mat mtmul(mat& A, mat& B) { mat C(A.size(), vec(B[0].size())); rep(i, (int)A.size()) { rep(k, (int)B.size()) { rep(j, (int)B[0].size()) { C[i][j] = (C[i][j] + (A[i][k] * B[k][j])); } } } return C; } mat mtpow(mat A, ll n) { mat B(A.size(), vec(A.size())); rep(i, (int)A.size()) { B[i][i] = 1; } while (n > 0) { if (n & (ll)1)B = mtmul(B, A); A = mtmul(A, A); n >>= 1; } return B; } bigint dp[2]; bigint calc(ll n) { mat A = { {1,1},{1,0} }; A = mtpow(A, n); return A[0][1]; } void solve() { ll n; cin >> n; if (n == 2) { cout << "INF\n"; cout << 0 << "\n"; return; } bigint ans = calc(n); bigint p = calc(n / 2); if (n % 2 == 0)ans = ans - calc(n / 2) * calc(n / 2); cout << n << "\n"; cout << ans << "\n"; } signed main() { ios::sync_with_stdio(false); cin.tie(0); //cout << fixed << setprecision(15); //init_f(); //expr(); //int t; cin >> t; rep(i, t) solve(); return 0; }