#include #include #include #include #include #include #include #include using namespace std; #define GET_ARG(a,b,c,F,...) F #define REP3(i,s,e) for (i = s; i <= e; i++) #define REP2(i,n) REP3 (i,0,(int)(n)-1) #define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__) #define RREP3(i,s,e) for (i = s; i >= e; i--) #define RREP2(i,n) RREP3 (i,(int)(n)-1,0) #define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__) #define DEBUG(x) cerr << #x ": " << x << endl int dp[2][50001][2]; int main(void) { string s; cin >> s; int i, j, k, l, n = s.size(); int mod[2]; mod[0] = 1e9; mod[1] = 1e9+7; dp[0][0][1] = 1; dp[1][0][1] = 1; REP (i,2) REP (j,(n+1)/2) REP (k,10) { if (j == 0 && k == 0) continue; dp[i][j+1][0] = (dp[i][j+1][0] + dp[i][j][0]) % mod[i]; if (k < s[j] - '0') dp[i][j+1][0] = (dp[i][j+1][0] + dp[i][j][1]) % mod[i]; if (k == s[j] - '0') dp[i][j+1][1] = (dp[i][j+1][1] + dp[i][j][1]) % mod[i]; } int ans[2] {}; long long x[2] {9,9}; REP (i,2) REP (j,n/2) { ans[i] = (ans[i] + x[i]) % mod[i]; if ((j+1) * 2 <= n-1) ans[i] = (ans[i] + x[i]) % mod[i]; x[i] = (x[i] * 10) % mod[i]; } REP (i,2) ans[i] = (ans[i] + dp[i][(n+1)/2][0]) % mod[i]; bool ok = true; RREP (i,n/2) { if (s[i] < s[n-1-i]) break; ok &= s[i] == s[n-1-i]; } REP (i,2) ans[i] = (ans[i] + ok) % mod[i]; REP (i,2) cout << ans[i] << endl; return 0; }