#include #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--) #define rep(i, n) for (ll i = 0; i < (n); i++) #define rep1(i, n) for (ll i = 1; i <= (n); i++) #define rrep(i, n) for (ll i = (n)-1; i >= 0; i--) #define pb push_back #define mp make_pair #define fst first #define snd second #define show(x) cout << #x << " = " << x << endl #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) #define pii pair #define vi vector using namespace std; template ostream& operator<<(ostream& o, const pair& p) { return o << "(" << p.first << "," << p.second << ")"; } template ostream& operator<<(ostream& o, const vector& vc) { o << "sz = " << vc.size() << endl << "["; for (const T& v : vc) o << v << ","; o << "]"; return o; } using ll = long long; constexpr ll MOD1 = 1e9; constexpr ll MOD2 = 1000000007; constexpr int MAX = 100000; int main() { string str; cin >> str; const int digit = str.size(); if (digit == 1) { cout << str << endl; cout << str << endl; return 0; } vector digits(digit); rep(i, digit) { digits[i] = str[i] - '0'; } bool ispower = true; rep(i, digit) { if (i == 0) { if (digits[i] != 1) { ispower = false; break; } } else { if (digits[i] != 0) { ispower = false; break; } } } { ll num1 = 0; ll n = 1; for (int i = 1; i < digit; i++) { if (i % 2 == 1) { if (i == 1) { n = (n * 9) % MOD1; num1 = (num1 + n) % MOD1; } else { n = (n * 10) % MOD1; num1 = (num1 + n) % MOD1; } } else { num1 = (num1 + n) % MOD1; } } const int half = (digit - 1) / 2; bool flag = true; for (int i = half; i >= 0; i--) { if (digits[digit - i - 1] > digits[i]) { flag = true; break; } else if (digits[digit - i - 1] < digits[i]) { flag = false; } } ll num = 0; ll comp = 1; for (int i = 0; i <= half; i++) { if (i > 0) { comp = (comp * 10) % MOD1; } num = (num * 10) % MOD1; num = (num + digits[i]) % MOD1; } if (not flag) { num--; } cout << ((1 + num1 + num - comp) % MOD1 + MOD1) % MOD1 << endl; } { ll num2 = 0; ll n = 1; for (int i = 1; i < digit; i++) { if (i % 2 == 1) { if (i == 1) { n = (n * 9) % MOD2; num2 = (num2 + n) % MOD2; } else { n = (n * 10) % MOD2; num2 = (num2 + n) % MOD2; } } else { num2 = (num2 + n) % MOD2; } } const int half = (digit - 1) / 2; bool flag = true; for (int i = half; i >= 0; i--) { if (digits[digit - i - 1] > digits[i]) { flag = true; break; } else if (digits[digit - i - 1] < digits[i]) { flag = false; } } ll num = 0; ll comp = 1; for (int i = 0; i <= half; i++) { if (i > 0) { comp = (comp * 10) % MOD2; } num = (num * 10) % MOD2; num = (num + digits[i]) % MOD2; } if (not flag) { num--; } cout << ((1 + num2 + num - comp) % MOD2 + MOD2) % MOD2 << endl; } return 0; }