Problem: Let S(n) denote the number that represents the digits of n in sorted order. For example, S(1) = 1, S(5) = 5, S(50394) = 3459, S(353535) = 333555.

Given a number X, compute <image> modulo 109 + 7.

Input

The first line of input will contain the integer X (1 ≤ X ≤ 10700).

Output

Print a single integer, the answer to the question.

Examples

Input

21


Output

195


Input

345342


Output

390548434

Note

The first few values of S are 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 12. The sum of these values is 195. 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 710, P = 1000000007;
int n, ans, pw[maxn], cnt[10], fact[maxn], finv[maxn], tmp[11][maxn];
int suf1[10][maxn], suf2[10][maxn], foo[10][maxn], bar[10][maxn];
char s[maxn];
void inc(int &x, int y) {
  if ((x += y) >= P) x -= P;
}
void dec(int &x, int y) {
  if ((x -= y) < 0) x += P;
}
int qp(int x, int y) {
  int z = 1;
  for (; y; y >>= 1, x = 1LL * x * x % P) {
    if (y & 1) z = 1LL * z * x % P;
  }
  return z;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = pw[0] = 1; i <= n; i++) {
    pw[i] = 10LL * pw[i - 1] % P;
  }
  for (int i = fact[0] = finv[0] = 1; i <= n; i++) {
    fact[i] = 1LL * i * fact[i - 1] % P;
    finv[i] = qp(fact[i], P - 2);
  }
  for (int i = 0; i <= 10; i++) {
    for (int j = 0; j <= n; j++) {
      tmp[i][j] = qp(i, j);
    }
  }
  for (int i = 1; i <= 9; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= j; k++) {
        foo[i][j] =
            (foo[i][j] + 1LL * finv[k] * finv[j - k] % P * tmp[9 - i][k]) % P;
        bar[i][j] =
            (bar[i][j] + 1LL * finv[k] * finv[j - k] % P * tmp[i][k]) % P;
      }
    }
  }
  int cur = 1;
  for (int i = n - 1; ~i; i--, cur++) {
    for (int c = 1; c <= 9; c++) {
      memset(suf1[c], 0, sizeof(suf1[c]));
      memset(suf2[c], 0, sizeof(suf2[c]));
      for (int j = i; ~j; j--) {
        suf1[c][j] = suf1[c][j + 1], suf2[c][j] = suf2[c][j + 1];
        suf1[c][j] = (suf1[c][j] + 1LL * fact[i] * finv[j] % P * foo[c][i - j] %
                                       P * tmp[c][j]) %
                     P;
        suf2[c][j] = (suf2[c][j] + 1LL * fact[i] * finv[j] % P * bar[c][i - j] %
                                       P * tmp[9 - c][j]) %
                     P;
      }
    }
    for (int j = 0; j < s[cur] - '0'; j++) {
      cnt[j]++;
      for (int k = 1; k <= 9; k++) {
        int pre = 0, suf = 0;
        for (int l = 0; l <= 9; l++) {
          if (l < k) pre += cnt[l];
          if (l > k) suf += cnt[l];
        }
        for (int pos = 1; pos <= n; pos++)
          if (pos > pre && pos <= n - suf) {
            int b1 = min(i, pos - pre - 1), b2 = min(i, n - pos - suf);
            int coef =
                (1LL * suf1[k][0] - suf1[k][b1 + 1] - suf2[k][b2 + 1] + 2 * P) %
                P;
            ans = (ans + 1LL * coef * k % P * pw[n - pos]) % P;
          }
      }
      cnt[j]--;
    }
    cnt[s[cur] - '0']++;
  }
  sort(s + 1, s + n + 1);
  for (int i = 1; i <= n; i++) {
    ans = (ans + 1LL * (s[i] - '0') * pw[n - i]) % P;
  }
  printf("%d\n", ans);
  return 0;
}