#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
inline int add(int x, int y) { return x + y >= MOD ? x + y - MOD : x + y; }
inline int sub(int x, int y) { return x - y < 0 ? x - y + MOD : x - y; }
inline int mul(int x, int y) { return 1LL * x * y % MOD; }
inline void Add(int &x, int y) { (x += y) >= MOD && (x -= MOD); }
inline void Sub(int &x, int y) { (x -= y) < 0 && (x += MOD); }
inline void Mul(int &x, int y) { x = 1LL * x * y % MOD; }
const int N = 1e3 + 10;
inline int id(char x) {
  if (isupper(x)) return x - 'A';
  if (islower(x)) return x - 'a';
  if (isdigit(x)) return x - '0';
  return -1;
}
int len, d, d2;
int a[N], b[N], dp[N][N * 25][2], awa[66][2];
char s[N], D[N], U[N];
template <int N, int S>
struct AhoCorasick {
  int tot;
  int ch[N][S], fail[N], end[N];
  inline void insert(char *s) {
    int u = 0;
    for (int i = 1; i <= d2; ++i) {
      int v = id(s[i]);
      if (!ch[u][v]) ch[u][v] = ++tot;
      u = ch[u][v];
    }
    end[u] = 1;
  }
  std::queue<int> Q;
  inline void buildFail() {
    for (int i = 0; i < S; ++i)
      if (ch[0][i]) Q.push(ch[0][i]);
    for (; !Q.empty(); Q.pop()) {
      int u = Q.front();
      for (int i = 0; i < S; ++i)
        if (ch[u][i])
          fail[ch[u][i]] = ch[fail[u]][i], Q.push(ch[u][i]);
        else
          ch[u][i] = ch[fail[u]][i];
    }
  }
  inline void print() {
    printf("tot = %d\n", tot);
    for (int i = 0; i <= tot; ++i) {
      printf("Node %d:\n", i);
      printf("END: %d\n", end[i]);
      printf("FAIL: %d\n", fail[i]);
      puts("Childrens:");
      for (int j = 0; j < 10; ++j) printf("%d ", ch[i][j]);
      puts("");
      puts("--------------------------------");
    }
  }
};
AhoCorasick<N * 25, 10> Siyuan;
inline int gao(int *a) {
  memset(dp, 0, sizeof(dp)), dp[0][0][1] = 1;
  awa[d + 1][0] = awa[d + 1][1] = 1;
  for (int i = d; i; --i)
    awa[i][0] = mul(awa[i + 1][0], 10),
    awa[i][1] = add(mul(a[i], awa[i + 1][0]), awa[i + 1][1]);
  for (int i = 0; i < d; ++i)
    for (int j = 0; j <= Siyuan.tot; ++j)
      if (!Siyuan.end[j])
        for (int k = 0; k < 10; ++k) {
          int v = Siyuan.ch[j][k];
          Add(dp[i + 1][v][0], dp[i][j][0]);
          if (k < a[i + 1]) Add(dp[i + 1][v][0], dp[i][j][1]);
          if (k == a[i + 1]) Add(dp[i + 1][v][1], dp[i][j][1]);
        }
  int ans = 0;
  for (int i = 1; i <= d; ++i)
    for (int j = 0; j <= Siyuan.tot; ++j)
      if (Siyuan.end[j])
        Add(ans, add(mul(dp[i][j][0], awa[i + 1][0]),
                     mul(dp[i][j][1], awa[i + 1][1])));
  return ans;
}
inline bool check(int *a) {
  int u = 0;
  for (int i = 1; i <= d; ++i) {
    u = Siyuan.ch[u][a[i]];
    if (Siyuan.end[u]) return 1;
  }
  return 0;
}
int main() {
  scanf(" %s %s %s", s + 1, D + 1, U + 1);
  len = strlen(s + 1), d = strlen(D + 1), d2 = d >> 1;
  for (int i = 1; i <= d; ++i) a[i] = id(D[i]), b[i] = id(U[i]);
  for (int i = 0; i + d2 <= len; ++i) Siyuan.insert(s + i);
  Siyuan.buildFail();
  printf("%d\n", add(sub(gao(b), gao(a)), check(a)));
  return 0;
}
