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)); } struct MInt { enum MO0 = 10L^^9; enum MO1 = 10L^^9 + 7; long v0, v1; this(long v) { v0 = v % MO0; v1 = v % MO1; } this(long v0, long v1) { this.v0 = v0 % MO0; this.v1 = v1 % MO1; } MInt opBinary(string op)(MInt o) if (op == "+" || op == "*") { return MInt(mixin("v0 " ~ op ~ " o.v0"), mixin("v1 " ~ op ~ " o.v1")); } MInt opOpAssign(string op)(MInt o) if (op == "+" || op == "*") { return (this = mixin("this " ~ op ~ "o")); } } enum LIM = 3 * 10^^5; int L; string N; void main() { auto ten = new MInt[LIM]; ten[0] = MInt(1); foreach (i; 1 .. LIM) { ten[i] = ten[i - 1] * MInt(10); } try { for (; ; ) { N = readToken(); L = cast(int)(N.length); MInt ans; // of length l (< L) foreach (l; 1 .. L) { ans += MInt(9) * ten[(l + 1) / 2 - 1]; } // share first k digits foreach (k; 0 .. L + 1) { auto tmp = MInt(1); if (L - 1 - (k - 1) < k - 1) { if (N[L - 1 - (k - 1)] != N[k - 1]) { break; } } if (k < L) { int cnt; if (L - 1 - k < k) { tmp = MInt((N[L - 1 - k] < N[k]) ? 1 : 0); } else { tmp *= MInt((k == 0) ? (N[k] - '0' - 1) : (N[k] - '0')); tmp *= ten[(L + 1) / 2 - k - 1]; } } debug { writeln("k = ", k, ": ", tmp); } ans += tmp; } writeln(ans.v0); writeln(ans.v1); } } catch (EOFException e) { } }