#include <bits/stdc++.h>
const int maxn = 1005;
const int maxd = 55;
const int maxN = maxn * maxd;
const long long mod = 1E+9 + 7;
namespace ACAM {
int ind, fail[maxN], ch[maxN][10];
bool ed[maxN];
inline void insert(int u, char *p, char *end) {
  if (p == end) return ed[u] = 1, void();
  if (!ch[u][*p - '0']) ch[u][*p - '0'] = ++ind;
  insert(ch[u][*p - '0'], p + 1, end);
}
std::queue<int> q;
inline void Build() {
  for (int i = 0; i < 10; ++i)
    if (ch[0][i])
      q.push(ch[0][i]), fail[ch[0][i]] = 0;
    else
      ch[0][i] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < 10; ++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];
    }
  }
}
}  // namespace ACAM
int n, d;
long long dp[maxd][maxN][2];
inline long long DP(char *x) {
  for (int i = 1; i <= d; ++i)
    for (int j = 0; j <= ACAM::ind; ++j) dp[i][j][0] = dp[i][j][1] = 0;
  dp[0][0][1] = 1;
  for (int i = 0; i < d; ++i) {
    for (int u = 0; u <= ACAM::ind; ++u) {
      if (!ACAM::ed[u])
        for (int c = 0; c < 10; ++c) {
          int v = ACAM::ch[u][c];
          dp[i + 1][v][0] += dp[i][u][0];
          if (c < x[i + 1] - '0') dp[i + 1][v][0] += dp[i][u][1];
          if (c == x[i + 1] - '0') dp[i + 1][v][1] += dp[i][u][1];
          dp[i + 1][v][0] %= mod, dp[i + 1][v][1] %= mod;
        }
    }
  }
  long long res = 0, p[2] = {1, 1};
  for (int i = d; i >= 1; --i) {
    for (int u = 0; u <= ACAM::ind; ++u)
      if (ACAM::ed[u]) (res += dp[i][u][0] * p[0] + dp[i][u][1] * p[1]) %= mod;
    p[1] = (p[0] * (x[i] - '0') + p[1]) % mod, p[0] = p[0] * 10 % mod;
  }
  return res;
}
char s[maxn], x[maxd], y[maxd];
int main() {
  scanf("%s", s + 1), n = strlen(s + 1);
  scanf("%s%s", x + 1, y + 1), d = strlen(x + 1);
  for (int i = 1; i + d / 2 - 1 <= n; ++i)
    ACAM::insert(0, s + i, s + i + d / 2);
  ACAM::Build();
  --x[d];
  for (int t = d; t && x[t] < '0'; --t) x[t] = '9', --x[t - 1];
  printf("%lld", (DP(y) - DP(x) + mod) % mod);
}
