#include <bits/stdc++.h>
using namespace std;
namespace io {
const int SI = 1 << 21 | 1;
char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
int f, t;
inline void flush() { fwrite(OB, 1, OS - OB, stdout), OS = OB; }
inline void pc(char x) {
  *OS++ = x;
  if (OS == OT) flush();
}
template <class I>
inline void rd(I &x) {
  for (f = 1, c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                              IS == IT ? EOF : *IS++)
                            : *IS++);
       c < '0' || c > '9';
       c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                       IS == IT ? EOF : *IS++)
                     : *IS++))
    if (c == '-') f = -1;
  for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15),
      c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                      IS == IT ? EOF : *IS++)
                    : *IS++))
    ;
  x *= f;
}
inline void rds(char *s, int &x) {
  for (c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                       IS == IT ? EOF : *IS++)
                     : *IS++);
       c < 33 || c > 126;
       c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                       IS == IT ? EOF : *IS++)
                     : *IS++))
    ;
  for (x = 0; c >= 33 && c <= 126;
       s[++x] = c, c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                                   IS == IT ? EOF : *IS++)
                                 : *IS++))
    ;
  s[x + 1] = '\0';
}
template <class I>
inline void print(I x, char k = '\n') {
  if (!x) pc('0');
  if (x < 0) pc('-'), x = -x;
  while (x) ch[++t] = x % 10 + '0', x /= 10;
  while (t) pc(ch[t--]);
  pc(k);
}
inline void prints(string s) {
  int x = s.length();
  while (t < x) pc(s[t++]);
  pc('\n'), t = 0;
}
struct Flush {
  ~Flush() { flush(); }
} flusher;
}  // namespace io
using io::print;
using io::prints;
using io::rd;
using io::rds;
struct modint {
  int x;
  inline modint(int x = 0) : x(x) {}
  inline modint &operator=(int o) { return x = o, *this; }
  inline modint &operator+=(modint o) {
    return x = x + o.x >= 1000000007 ? x + o.x - 1000000007 : x + o.x, *this;
  }
  inline modint &operator-=(modint o) {
    return x = x - o.x < 0 ? x - o.x + 1000000007 : x - o.x, *this;
  }
  inline modint &operator*=(modint o) {
    return x = 1ll * x * o.x % 1000000007, *this;
  }
  inline modint &operator^=(long long b) {
    modint a = *this, c;
    if (!~b) b = 1000000007 - 2;
    c.x = 1 % 1000000007;
    while (b) {
      if (b & 1) c *= a;
      a *= a, b >>= 1;
    }
    return x = c.x, *this;
  }
  inline modint &operator/=(modint o) { return *this *= o ^= -1; }
  inline modint &operator+=(int o) {
    return x = x + o >= 1000000007 ? x + o - 1000000007 : x + o, *this;
  }
  inline modint &operator-=(int o) {
    return x = x - o < 0 ? x - o + 1000000007 : x - o, *this;
  }
  inline modint &operator*=(int o) {
    return x = 1ll * x * o % 1000000007, *this;
  }
  inline modint &operator/=(int o) {
    modint y = modint(o);
    return *this *= y ^= -1;
  }
  template <class I>
  inline friend modint operator+(modint a, I b) {
    return a += b;
  }
  template <class I>
  inline friend modint operator-(modint a, I b) {
    return a -= b;
  }
  template <class I>
  inline friend modint operator*(modint a, I b) {
    return a *= b;
  }
  inline friend modint operator^(modint a, long long b) { return a ^= b; }
  template <class I>
  inline friend modint operator/(modint a, I b) {
    return a /= b;
  }
  inline friend bool operator==(modint a, int b) { return a.x == b; }
  inline bool operator!() { return !x; }
  inline modint operator-() { return x ? 1000000007 - x : 0; }
};
inline void rd(modint &x) { rd(x.x); }
inline void print(modint x, char k = '\n') { print(x.x, k); }
const int N = 1e3 + 7, D = 53, K = 11;
int n, d, trie[N * D][K], ed[N * D], fail[N * D], tot = 1;
char s[N], a[D], b[D];
modint p[N][2], f[D][N * D][2];
inline void build() {
  int m = d / 2;
  for (int i = 1; i + m - 1 <= n; i++) {
    int p = 1;
    for (int j = i, k = 1; k <= m; j++, k++) {
      int c = s[j] - '0';
      if (!trie[p][c]) trie[p][c] = ++tot;
      p = trie[p][c];
    }
    ed[p] = 1;
  }
  queue<int> q;
  for (int i = 0; i < 10; i++)
    if (trie[1][i]) {
      fail[trie[1][i]] = 1;
      q.push(trie[1][i]);
    } else
      trie[1][i] = 1;
  while (q.size()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < 10; i++)
      if (trie[x][i]) {
        fail[trie[x][i]] = trie[fail[x]][i];
        q.push(trie[x][i]);
      } else
        trie[x][i] = trie[fail[x]][i];
  }
}
inline modint calc(char *t) {
  p[d + 1][0] = p[d + 1][1] = 1;
  for (int i = d; i; i--) {
    p[i][0] = p[i + 1][0] * 10;
    p[i][1] = (t[i] - '0') * p[i + 1][0] + p[i + 1][1];
  }
  modint ans = 0;
  for (int i = 1; i <= d; i++)
    for (int j = 1; j <= tot; j++)
      for (int k = 0; k < 2; k++) f[i][j][k] = 0;
  f[0][1][1] = 1;
  for (int i = 0; i < d; i++)
    for (int j = 1; j <= tot; j++)
      if (!ed[j])
        for (int k = 0; k < 10; k++) {
          int o = trie[j][k];
          f[i + 1][o][0] += f[i][j][0];
          if (k < t[i + 1] - '0') f[i + 1][o][0] += f[i][j][1];
          if (k == t[i + 1] - '0') f[i + 1][o][1] += f[i][j][1];
        }
  for (int i = 1; i <= d; i++)
    for (int j = 1; j <= tot; j++)
      if (ed[j]) {
        ans += f[i][j][0] * p[i + 1][0] + f[i][j][1] * p[i + 1][1];
      }
  return ans;
}
int main() {
  rds(s, n), rds(a, d), rds(b, d), build();
  int k = d;
  while (a[k] == '0') a[k--] = '9';
  --a[k];
  print(calc(b) - calc(a));
  return 0;
}
