// yukicoder: No.528 10^9と10^9+7と回文 // 2019.6.28 bal4u #include typedef long long ll; #if 1 #define gc() getchar_unlocked() #define pc(c) putchar_unlocked(c) #else #define gc() getchar() #define pc(c) putchar(c) #endif int ins(char *s) { int w = 0, c; while ((c = gc()) > ' ') w++, *s++ = c & 0xf; return w; } void out(int n) { int i; char ob[20]; if (!n) pc('0'); else { i = 0; while (n) ob[i++] = n%10 + '0', n/=10; while (i--) pc(ob[i]); } pc('\n'); } #define M1 1000000000 #define M2 1000000007 char S[100005]; int w; int check(int i, int r) { while (i <= r) { if (S[i] < S[w-i-1]) { while (S[i] == 0) S[i--] = 9; S[i]--; return i; } i++; } return i; } int main() { int i, k, x, a1, a2, t1, t2; ll p1, p2; w = ins(S); if (w == 1) { out(S[0]), out(S[0]); return 0; } k = w >> 1; x = w; while ((i = check(w-k, x)) < x && i >= w-k) x = i; if (--w & 1) k--; if (S[0] == 0) a1 = a2 = 0; else { a1 = a2 = S[k] + (k > 0); i = k - 1, p1 = p2 = 10; while (i >= 0) { x = S[i] - (i == 0 && S[w]); a1 = (a1 + x * p1) % M1, a2 = (a2 + x * p2) % M2; p1 = p1 * 10 % M1, p2 = p2 * 10 % M2; i--; } } t1 = t2 = 9; for (i = 0; i < w; i++) { if (t1 == 0) break; a1 = (a1 + t1) % M1, a2 = (a2 + t2) % M2; if (++i >= w) break; a1 = (a1 + t1) % M1, a2 = (a2 + t2) % M2; t1 = t1 * 10LL % M1, t2 = t2 * 10LL % M2; } while (i < w) { a2 = (a2 + t2) % M2; if (++i >= w) break; a2 = (a2 + t2) % M2, t2 = t2 * 10LL % M2; i++; } out(a1), out(a2); return 0; }