#include <bits/stdc++.h>
using namespace std;
int power(int a, int b, int c, int ans = 1) {
  for (; b; b >>= 1, a = (long long)a * a % c)
    if (b & 1) ans = (long long)ans * a % c;
  return ans;
}
const int mod = 1000000007, NN = 1010;
int p[55], nxt[NN * 55][10], n, id[NN][NN], dep[NN * 55];
int dp[55][NN * 55][2];
char s[NN];
int calc(int u, int first, int ok) {
  if (u == n) return !ok && dep[first] >= n >> 1;
  int &ans = dp[u][first][ok];
  if (~ans) return ans;
  ans = 0;
  if (dep[first] >= n >> 1) {
    if (ok) {
      for (int i = u; i < n; i++) ans = (ans * 10LL + s[i] - '0') % mod;
    } else {
      ans = p[n - u];
    }
  } else {
    for (int j = 0, d = ok ? s[u] - '0' + 1 : 10; j < d; j++) {
      ans = (ans + calc(u + 1, nxt[first][j], ok && j == s[u] - '0')) % mod;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; i++) s[i] -= '0';
  int cur = 0;
  for (int i = 0; i < n; i++) {
    int p = 0;
    for (int j = i, ed = min(n, i + 51); j < ed; j++) {
      if (!nxt[p][s[j]]) nxt[p][s[j]] = ++cur;
      p = nxt[p][s[j]];
      dep[p] = j - i + 1;
      id[i][j - i + 1] = p;
    }
  }
  for (int j = 1; j <= 51; j++) {
    for (int i = 0; i + j <= n; i++) {
      for (int r = 0; r < 10; r++)
        if (!nxt[id[i][j]][r]) {
          nxt[id[i][j]][r] = nxt[id[i + 1][j - 1]][r];
        }
    }
  }
  for (int i = p[0] = 1; i < 55; i++) p[i] = p[i - 1] * 10LL % mod;
  scanf("%s", s);
  n = strlen(s);
  memset(dp, -1, sizeof dp);
  int ans = calc(0, 0, 1);
  scanf("%s", s);
  n = strlen(s);
  memset(dp, -1, sizeof dp);
  ans = (mod - ans + calc(0, 0, 1)) % mod;
  for (int i = 0, q = 0; i < n; i++) {
    q = nxt[q][s[i] - '0'];
    if (dep[q] >= n / 2) {
      ans = (ans + 1) % mod;
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}
