#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; const int p1 = (int)1e9, p2 = (int)1e9 + 7; typedef pair Val; Val add(Val x, Val y) { (x.first += y.first) %= p1; (x.second += y.second) %= p2; return x; } Val mul(Val x, Val y) { (x.first *= y.first) %= p1; (x.second *= y.second) %= p2; return x; } int main(){ ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int l = sz(s); each(c, s)c -= '0'; if (l == 1) { cout << (int)s[0] << endl; cout << (int)s[0] << endl; return 0; } Val ans(0, 0); ans = add(ans, Val(9, 9)); Val aa(1, 1); for (int i = 2; i < l; ++i) { Val x(0, 0); if (i % 2) aa = mul(aa, Val(10, 10)); ans = add(ans, mul(aa, Val(9, 9))); } vector pw(l + 1); pw[0] = Val(1, 1); rep(i, l)pw[i + 1] = mul(pw[i], Val(10, 10)); rep(i, l / 2) { if (i > 0 && s[i - 1] != s[l - 1 - (i - 1)]) { break; } int float_len = (l - (i + 1) * 2 + 1) / 2; if (s[i] > 1 || (i > 0 && s[i] > 0)) { if(i>0)ans = add(ans, mul(Val(s[i], s[i]), pw[float_len])); else ans = add(ans, mul(Val(s[i] - 1, s[i] - 1), pw[float_len])); } } bool isPalin = true; rep(i, l / 2)if (s[i] != s[l - 1 - i]) { isPalin = false; break; } if (isPalin) { if (l % 2)ans = add(ans, Val(s[l / 2]+1, s[l / 2]+1)); else ans = add(ans, Val(1, 1)); } cout << ans.first << endl << ans.second << endl; }