#include <bits/stdc++.h>
using namespace std;
const int N = 3e4, M = 55, mo = 1e9 + 7;
int n, m, d, i, j, f[N][M], ans;
char s[1005], a[M];
int nd, tr[N][10], fail[N];
bool hv[N];
int h, t, q[N];
void build() {
  for (int i = 0; i <= 9; i++)
    if (tr[0][i]) q[++t] = tr[0][i];
  while (h != t)
    for (int x = q[++h], i = 0; i <= 9; i++)
      if (!tr[x][i])
        tr[x][i] = tr[fail[x]][i];
      else
        fail[tr[x][i]] = tr[fail[x]][i], q[++t] = tr[x][i];
}
void init() {
  for (i = 0; i <= n - d; i++) {
    int x = 0;
    for (j = i; j <= i + d - 1; j++) {
      int k = s[j] - 48;
      if (!tr[x][k]) tr[x][k] = ++nd;
      x = tr[x][k];
    }
    hv[x] = 1;
  }
  build();
  int pw = 10;
  for (i = 0; i <= nd; i++)
    if (hv[i]) f[i][0] = 1;
  for (j = 1; j < m; j++, pw = 10ll * pw % mo)
    for (i = 0; i <= nd; i++) {
      if (hv[i]) {
        f[i][j] = pw;
        continue;
      }
      for (int x = 0; x <= 9; x++)
        f[i][j] = (f[i][j] + f[tr[i][x]][j - 1]) % mo;
    }
}
int cal() {
  int ans = 0, x = 0;
  for (int i = 1; i <= m; i++) {
    for (int k = 0; k < a[i]; k++) ans = (ans + f[tr[x][k]][m - i]) % mo;
    if (hv[x = tr[x][a[i]]]) {
      int num = 0;
      for (int j = i + 1; j <= m; j++) num = (10ll * num + a[j]) % mo;
      return (ans + num + 1) % mo;
    }
  }
  return ans;
}
int main() {
  scanf("%s%s", s, a + 1);
  n = strlen(s);
  m = strlen(a + 1);
  d = m >> 1;
  for (i = 1; i <= m; i++) a[i] -= 48;
  for (i = m, a[m]--; a[i] < 0; a[i] += 10, i--, a[i]--)
    ;
  init();
  ans = mo - cal();
  scanf("%s", a + 1);
  for (i = 1; i <= m; i++) a[i] -= 48;
  printf("%d\n", (ans + cal()) % mo);
}
