#include <bits/stdc++.h>
const int Mod = 1e9 + 7;
int n, ans, que[1005 * 25], N, d;
char s[1005], A[55];
int cnt, son[1005 * 25][10], dp[2][1005 * 25], now, fail[1005 * 25], ten[55];
int pos;
bool end[1005 * 25];
void getfail() {
  for (int i = 0; i < 10; i++)
    if (son[0][i]) que[++cnt] = son[0][i];
  for (int l = 1; l <= cnt;) {
    int x = que[l++];
    for (int i = 0; i < 10; i++) {
      if (son[x][i]) {
        fail[son[x][i]] = son[fail[x]][i];
        que[++cnt] = son[x][i];
      } else
        son[x][i] = son[fail[x]][i];
    }
  }
}
void ty(long long oo) {
  memset(dp[1], 0, sizeof dp[1]);
  pos = 0;
  for (int i = d, now = 0; i; i--, now ^= 1) {
    int u = A[d - i + 1] - '0';
    memset(dp[now], 0, sizeof dp[now]);
    for (int j = 0; j <= cnt; j++) {
      if (!dp[now ^ 1][j]) continue;
      for (int k = 0; k < 10; k++) {
        int go = son[j][k];
        if (end[go])
          ans = (ans + oo * dp[now ^ 1][j] * ten[i - 1]) % Mod;
        else
          dp[now][go] = (dp[now][go] + dp[now ^ 1][j]) % Mod;
      }
    }
    if (pos != -1) {
      for (int j = 0; j < u; j++) {
        int go = son[pos][j];
        if (end[go])
          ans = (ans + oo * ten[i - 1]) % Mod;
        else
          dp[now][go] = (dp[now][go] + 1) % Mod;
      }
      pos = son[pos][u];
      if (end[pos]) {
        int x = 0;
        for (int j = i - 1; j; j--) x = (10ll * x - '0' + A[d - j + 1]) % Mod;
        ans = (ans + oo * x + (oo == 1)) % Mod;
        pos = -1;
      }
    }
  }
}
int main() {
  scanf("%s%s", s + 1, A + 1);
  n = std::strlen(s + 1);
  d = std::strlen(A + 1);
  for (int i = 1; i <= n - d / 2 + 1; i++) {
    int x = 0;
    for (int j = i; j <= i + d / 2 - 1; x = son[x][s[j++] - '0'])
      if (!son[x][s[j] - '0']) son[x][s[j] - '0'] = ++N;
    end[x] = 1;
  }
  getfail();
  ten[0] = 1;
  for (int i = 1; i <= d; i++) ten[i] = (long long)ten[i - 1] * 10 % Mod;
  ty(-1);
  scanf("%s", A + 1);
  ty(1);
  printf("%d\n", (ans % Mod + Mod) % Mod);
}
