#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,n) for(int i=0; i=b; --i) #define ALL(c) c.begin(), c.end() typedef long long ll; typedef vector VI; typedef vector VL; typedef vector VVI; typedef pair P; typedef pair PL; const ll mod1 = 1e9, mod2 = 1e9 + 7; ll dp1[100010][3], dp2[100010][3]; ll powll(ll x, ll y, ll m){ ll res = 1LL; while(y){ if (y & 1LL) res *= x; res %= m; x = (x*x) % m; y >>= 1LL; } return res; } int main() { string s; cin >> s; int n = s.length(); ll ans1 = 0, ans2 = 0; FOR(i,1,n-1){ ans1 = (ans1 + 9 * powll(10, (i+1)/2-1, mod1)) % mod1; ans2 = (ans2 + 9 * powll(10, (i+1)/2-1, mod2)) % mod2; } dp1[0][0] = 1; dp2[0][0] = 1; REP(i,(n+1)/2) REP(j,2){ if (j == 1){ REP(k,10){ (dp1[i+1][1] += dp1[i][1]) %= mod1; (dp2[i+1][1] += dp2[i][1]) %= mod2; } }else{ int l = (i == 0 ? 1 : 0); // int r = min(s[i] - '0', s[n-1-i] - '0'); int lim = s[i] - '0'; // FOR(k,l,r){ // (dp1[i+1][j || k < lim] += dp1[i][j]) %= mod1; // (dp2[i+1][j || k < lim] += dp2[i][j]) %= mod2; // } FOR(k,l,9){ if (k < lim){ (dp1[i+1][1] += dp1[i][0] + dp1[i][2]) %= mod1; (dp2[i+1][1] += dp2[i][0] + dp2[i][2]) %= mod2; }else if (k == lim && k <= s[n-1-i] - '0'){ (dp1[i+1][0] += dp1[i][0]) %= mod1; (dp2[i+1][0] += dp2[i][0]) %= mod2; }else if (k == lim){ (dp1[i+1][2] += dp1[i][0]) %= mod1; (dp2[i+1][2] += dp2[i][0]) %= mod2; } } } } int m = (n+1)/2; ans1 = (ans1 + dp1[m][0] + dp1[m][1] + dp1[m][2]) % mod1; ans2 = (ans2 + dp2[m][0] + dp2[m][1] + dp2[m][2]) % mod2; cout << ans1 << endl << ans2 << endl; }