import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.bigint; // BigInt void main() { auto l = readln.chomp.to!int; if (l == 1) { writeln(1); writeln(1); } else if (l == 2) { writeln(3); writeln("INF"); } else { writeln(l); auto r = calc(l); if (l % 2 == 0) { auto s = calc(l/2); writeln(r - s * s); } else { writeln(r); } } } auto calc(int l) { auto o = BigInt(1), z = BigInt(0); auto a = [[o,o],[o,z]]; auto im = [[o,z],[z,o]]; auto b = repeatedSquare!(BigInt[][], matMul)(a, l-2, im); return matMulVec(b, [o,o])[0]; } T[][] matMul(T)(T[][] a, T[][] b) { auto l = b.length, m = a.length, n = b[0].length; auto c = new T[][](m, n); foreach (i; 0..m) foreach (j; 0..n) foreach (k; 0..l) c[i][j] += a[i][k] * b[k][j]; return c; } T[] matMulVec(T)(T[][] a, T[] b) { auto l = b.length, m = a.length; auto c = new T[](m); foreach (i; 0..m) foreach (j; 0..l) c[i] += a[i][j] * b[j]; return c; } T repeatedSquare(T, alias pred = "a * b", U)(T a, U n, T init) { import std.functional; alias predFun = binaryFun!pred; if (n == 0) return init; static buf = new T[](32); static bufFilled = 0; if (bufFilled == 0) buf[bufFilled++] = a; auto r = init, i = 0; while (n > 0) { if ((n & 1) == 1) r = predFun(r, buf[i]); if (++i == bufFilled) buf[bufFilled++] = predFun(buf[i-1], buf[i-1]); n >>= 1; } return r; }