import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } real readReal() { return readToken.to!real; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } enum MO = 10UL^^9 + 7; struct P { long len; ulong sum, prod; P opBinary(string op)(in P o) const if (op == "*") { return P(len + o.len, sum + o.sum, (prod * o.prod) % MO); } } enum IDENTITY = P(0, 0, 1); enum LIM = 60; void main() { auto ss = new int[][LIM + 1]; auto ps = new P[LIM + 1]; ps[0] = IDENTITY; foreach (n; 1 .. LIM + 1) { ss[n] = (n^^2).to!string.map!(c => ((c == '0') ? 10 : cast(int)(c - '0'))).array; ps[n] = ps[n - 1] * P(ss[n].length, ss[n].sum, ss[n].fold!((a, b) => (a * b) % MO)) * ps[n - 1]; } debug { writeln("ss = ", ss); writeln("ps = ", ps); assert(ps[LIM].len >= 10L^^18); } P calc(int n, long l, long r) { debug { writeln("calc ", n, " [", l, ", ", r, ")"); } chmax(l, 0); chmin(r, ps[n].len); if (l >= r) { return IDENTITY; } P ret = IDENTITY; ret = ret * calc(n - 1, l, r); foreach (i; 0 .. ss[n].length) { if (l - ps[n - 1].len <= i && i < r - ps[n - 1].len) { ret = ret * P(1, ss[n][i], ss[n][i]); } } ret = ret * calc(n - 1, l - ps[n - 1].len - ss[n].length, r - ps[n - 1].len - ss[n].length); return ret; } try { for (; ; ) { int K = readInt(); const L = readLong() - 1; const R = readLong(); chmin(K, LIM); if (R > ps[K].len) { writeln(-1); } else { const ans = calc(K, L, R); assert(ans.len == R - L); writeln(ans.sum, " ", ans.prod); } } } catch (EOFException e) { } }