#include <bits/stdc++.h>
using namespace std;

const int N=2e5+5,MOD=1e9+7;

char s[N],x[N],y[N];

int c[N][11],fail[N],mark[N],ss;
void init()
{
    for(int i=0;i<=ss;i++){
        for(int j=0;j<10;j++)c[i][j]=0;
        fail[i]=mark[i]=0;
    }
    ss=0;
}
void add(char *s,int n)
{
    int now=0,t;
    for(int i=1;i<=n;i++){
        t=s[i]-'0';
        if(!c[now][t])c[now][t]=++ss;
        now=c[now][t];
    }
    mark[now]=1;
}
void build()
{
    queue<int>que;
    for(int i=0;i<10;i++)if(c[0][i])fail[c[0][i]]=0,que.push(c[0][i]);
    while(!que.empty()){
        int x=que.front();que.pop();
        mark[x]|=mark[fail[x]];
        for(int i=0;i<10;i++){
            if(c[x][i]){
                fail[c[x][i]]=c[fail[x]][i];
                que.push(c[x][i]);
            }
            else c[x][i]=c[fail[x]][i];
        }
    }
}

int LEN,D;

int f[52][1005*27][2][2];
int dfs(char *s,int x,int y,int lim,int ok)
{
    if(x>D){
        return ok;
    }

    if(f[x][y][lim][ok])return f[x][y][lim][ok];

    int up=lim?s[x]-'0':9;
    int res=0;
    for(int i=0;i<=up;i++){
        int t=c[y][i];
        (res+=dfs(s,x+1,t,lim&&i==up,ok|mark[t]))%=MOD;
    }

    f[x][y][lim][ok]=res;
    return res;
}

int cal(char *s)
{
    for(int i=0;i<=D;i++)
        for(int j=0;j<=ss;j++)
            for(int p1=0;p1<2;p1++)
                for(int p2=0;p2<2;p2++)
                    f[i][j][p1][p2]=0;
    return dfs(s,1,0,1,0);
}

int main()
{
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);

    int cas;
    for(cin>>cas;cas--;){
        cin>>s+1>>x+1>>y+1;

        LEN=strlen(s+1),D=strlen(x+1);
        for(int j=1;j<=LEN;j++){
            if(LEN-j+1>=D/2) add(s+j-1,D/2);
        }
        build();

        int t=D;x[t]--;
        while(x[t]<'0')x[t-1]--,x[t]+=10,t--;

        int res=(cal(y)-cal(x)+MOD)%MOD;
        cout<<res<<'\n';

        init();
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#define N 1005
#define ll long long
using namespace std;
int rt,cnt,n,d,lim[N];
ll dp[55][N*55][2][2];
char s1[N],s2[2][N];
const ll mod=1e9+7;
struct AC
{
	int ch[10],fail,ed;
}t[N*55];
void add(int l,int r)
{
	if(!rt)rt=++cnt;
	for(int i=l,nw=rt;i<=r;i++)
	{
		if(!t[nw].ch[s1[i]-'0'])t[nw].ch[s1[i]-'0']=++cnt;
		nw=t[nw].ch[s1[i]-'0'];
		if(i==l)t[nw].ed=1;
	}
}
queue<int>q;
void build()
{
	for(int i=0;i<10;i++)
	{
		int y=t[rt].ch[i];
		if(y)t[y].fail=rt,q.push(y);
		else t[rt].ch[i]=rt;
	}
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(int i=0;i<10;i++)
		{
			int y=t[x].ch[i];
			if(y)
			{
				t[y].fail=t[t[x].fail].ch[i],q.push(y);
				if(t[t[y].fail].ed)t[y].ed=1;
			}
			else t[x].ch[i]=t[t[x].fail].ch[i];
		}
	}
}
ll calc(int id)
{
	d=strlen(s2[id]+1);
	ll res=0;
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=d;i++)lim[i]=s2[id][i]-'0';
	for(int i=d,tmp=1;i>=1;i--,tmp=1ll*tmp*10%mod)
		res=(res+1ll*(s2[id][i]-'0')*tmp%mod)%mod;
	dp[0][rt][1][1]=1;
	for(int i=0;i<d;i++)
		for(int j=1;j<=cnt;j++)
			for(int k1=0;k1<=1;k1++)
				for(int k2=0;k2<=1;k2++)
				{
					if(!dp[i][j][k1][k2])continue;
					ll temp=dp[i][j][k1][k2];
					for(int x=0;x<=9;x++)
					{
						int j2=t[j].ch[x];
						if(!x&&k2)continue;
						if(t[j2].ed)continue;
						if(!k1)dp[i+1][j2][0][0]=(dp[i+1][j2][0][0]+temp)%mod;
						else if(x<lim[i+1])dp[i+1][j2][0][0]=(dp[i+1][j2][0][0]+temp)%mod;
						else if(x==lim[i+1])dp[i+1][j2][1][0]=(dp[i+1][j2][1][0]+temp)%mod;
					}
					if(k2)dp[i+1][rt][0][1]=(dp[i+1][rt][0][1]+temp)%mod;
				}
	for(int i=1;i<=cnt;i++)
		res=(res-dp[d][i][0][0]-dp[d][i][1][0]+mod)%mod;
	return res;
}
void change()
{
	for(int i=1;i*2<=d;i++)swap(s2[0][i],s2[0][d-i+1]);
	s2[0][1]--;
	for(int i=1;i<=d;i++)
	{
		if(s2[0][i]<'0')s2[0][i]='9',s2[0][i+1]--;
		else break;
	}
	if(s2[0][d]=='0')s2[0][d]=0,d--;
	for(int i=1;i*2<=d;i++)swap(s2[0][i],s2[0][d-i+1]);
}
int main()
{
	scanf("%s%s%s",s1+1,s2[0]+1,s2[1]+1);
	n=strlen(s1+1);
	d=strlen(s2[0]+1);
	change();
	d=strlen(s2[1]+1);
	for(int i=d/2;i<=n;i++)add(i-d/2+1,i);
	build();
	printf("%lld\n",(calc(1)-calc(0)+mod)%mod);
	return 0;
}


#include<bits/stdc++.h>
#define cs const
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
cs int N = 2e3 + 50;
cs int M = 55;
cs int Mod = 1e9 + 7;
int add(int a, int b){ return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b){ return a - b < 0 ? a - b + Mod : a - b; }
void Add(int &a, int b){ a = add(a,b); }
void Dec(int &a, int b){ a = dec(a,b); }
int n, d, a[M]; char S[N];
namespace SAM{
	int ch[N][10], len[N], lk[N], nd=1, las=1;
	void extend(int c){
		int now=++nd, p=las; len[now]=len[p]+1; las=now;
		for(;p&&!ch[p][c];p=lk[p]) ch[p][c]=now;
		if(!p){ lk[now]=1; return; }
		int q=ch[p][c]; if(len[q]==len[p]+1){ lk[now]=q; return; }
		int cl=++nd; len[cl]=len[p]+1; lk[cl]=lk[q]; lk[q]=lk[now]=cl;
		memcpy(ch[cl],ch[q],sizeof(ch[q]));
		for(;p&&ch[p][c]==q; p=lk[p]) ch[p][c]=cl;
	} int trs[N][10];
	void pre_work(){
		static int bin[N], A[N];
		for(int i=1; i<=nd; i++) bin[len[i]]++;
		for(int i=1; i<=n; i++) bin[i]+=bin[i-1];
		for(int i=nd; i>=1; i--) A[bin[len[i]]--]=i;
		for(int i=1; i<=nd; i++)
		for(int c=0; c<10; c++){
			int x=trs[lk[A[i]]][c];
			if(!ch[A[i]][c]) trs[A[i]][c]=x;
			else trs[A[i]][c]=A[i];
		}
	}
	void trans(int &x, int &l, int c){
		if(ch[x][c]){ ++l; x=ch[x][c]; return; }
		x=trs[x][c]; if(!x) x=1; l=len[x];
		if(ch[x][c]) ++l, x=ch[x][c];
	}
}
int dp[M][N][M][2][2];
int dfs(int u, int nd, int len, bool hv, bool lim){
	if(!u) return hv;
	if(~dp[u][nd][len][hv][lim])
	return dp[u][nd][len][hv][lim];
	int up=lim?a[u]:9, as=0;
	int rd=nd, rl=len;
	for(int i=u==d?1:0; i<=up; i++){
		nd=rd; len=rl; SAM::trans(nd,len,i);
		Add(as,dfs(u-1,nd,len,hv|(len>=(d+1)/2),lim&&(i==up)));
	} return dp[u][nd][len][hv][lim]=as;
}
int work(char *S, int dlt){
	int len=d;
	for(int i=1; i<=len; i++) a[i]=S[len-i+1]-'0';
	if(dlt){
		for(int i=1;a[i]==0&&i<d;i++) a[i]=9, --a[i+1];
		if(a[d]==0) return 0;
	} memset(dp,-1,sizeof(dp));
	return dfs(len,1,0,0,1);
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%s",S+1); n=strlen(S+1);
	for(int i=1; i<=n; i++) SAM::extend(S[i]-'0');
	SAM::pre_work();
	scanf("%s",S+1); d=strlen(S+1); int as=0;
	Dec(as,work(S,1));
	scanf("%s",S+1); d=strlen(S+1);
	Add(as,work(S,0)); cout<<as; return 0;
}


// Problem: CF585F Digits of Number Pi
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/CF585F
// Memory Limit: 250 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
//#include <immintrin.h>
//#include <emmintrin.h>

#include <bits/stdc++.h>
//#pragma GCC optimize("O2")
#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define all2(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define mt make_tuple
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define contain(S,X) (((S)&o(X))!=0)
#define containL(S,X) (((S)&oL(X))!=0)
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
inline int getplc(int x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}
// Smax
//int Smax() { return -INF; }
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
// Smin
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
// erro
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }

void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}
void Solve();
int main() {
#ifndef ONLINE_JUDGE
//	freopen("in.txt","r",stdin);
//    freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}

//////////////////////////////////////////////////////////////////

template<const int &MOD>
struct _m_int {
	int val;

	_m_int(int64_t v = 0) {
		if (v < 0) v = v % MOD + MOD;
		if (v >= MOD) v %= MOD;
		val = int(v);
	}

	static int inv_mod(int a, int m = MOD) {
		// https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Example
		int g = m, r = a, x = 0, y = 1;

		while (r != 0) {
			int q = g / r;
			g %= r; swap(g, r);
			x -= q * y; swap(x, y);
		}

		return x < 0 ? x + m : x;
	}

	explicit operator int() const { return val; }
	explicit operator int64_t() const { return val; }

	_m_int& operator+=(const _m_int &other) {
		val -= MOD - other.val;
		if (val < 0) val += MOD;
		return *this;
	}

	_m_int& operator-=(const _m_int &other) {
		val -= other.val;
		if (val < 0) val += MOD;
		return *this;
	}

	static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
#if !defined(_WIN32) || defined(_WIN64)
		return unsigned(x % m);
#endif
		// Optimized mod for Codeforces 32-bit machines.
		// x must be less than 2^32 * m for this to work, so that x / m fits in an unsigned 32-bit int.
		unsigned x_high = unsigned(x >> 32), x_low = unsigned(x);
		unsigned quot, rem;
		asm("divl %4\n"
		: "=a" (quot), "=d" (rem)
		: "d" (x_high), "a" (x_low), "r" (m));
		return rem;
	}

	_m_int& operator*=(const _m_int &other) {
		val = fast_mod(uint64_t(val) * other.val);
		return *this;
	}

	_m_int& operator/=(const _m_int &other) {
		return *this *= other.inv();
	}

	friend _m_int operator+(const _m_int &a, const _m_int &b) { return _m_int(a) += b; }
	friend _m_int operator-(const _m_int &a, const _m_int &b) { return _m_int(a) -= b; }
	friend _m_int operator*(const _m_int &a, const _m_int &b) { return _m_int(a) *= b; }
	friend _m_int operator/(const _m_int &a, const _m_int &b) { return _m_int(a) /= b; }

	_m_int& operator++() {
		val = val == MOD - 1 ? 0 : val + 1;
		return *this;
	}

	_m_int& operator--() {
		val = val == 0 ? MOD - 1 : val - 1;
		return *this;
	}

	_m_int operator++(int) { _m_int before = *this; ++*this; return before; }
	_m_int operator--(int) { _m_int before = *this; --*this; return before; }

	_m_int operator-() const {
		return val == 0 ? 0 : MOD - val;
	}

	bool operator==(const _m_int &other) const { return val == other.val; }
	bool operator!=(const _m_int &other) const { return val != other.val; }

	_m_int inv() const {
		return inv_mod(val);
	}

	_m_int pow(int64_t p) const {
		if (p < 0)
			return inv().pow(-p);

		_m_int a = *this, result = 1;

		while (p > 0) {
			if (p & 1)
				result *= a;

			p >>= 1;

			if (p > 0)
				a *= a;
		}

		return result;
	}

	friend ostream& operator<<(ostream &os, const _m_int &m) {
		return os << m.val;
	}
};

extern const int _MOD = 1e9+7;
using mint = _m_int<_MOD>;

struct state{
  int len,link;
  int next[26];
};
const int MAX_LEN=2*1e6+5;
state st[MAX_LEN];
int sz,last;
void sam_init(){
  st[0].len=0;
  st[0].link=-1;
  sz++;
  last=0;
}
int cnt[MAX_LEN];
void sam_extend(char c){
  int cur=sz++;
  cnt[cur]++;
  st[cur].len=st[last].len+1;
  int p=last;
  while(p!=-1&&!st[p].next[c]){
    st[p].next[c]=cur;
    p=st[p].link;
  }
  if(p==-1) st[cur].link=0;
  else{
    int q=st[p].next[c];
    if(st[p].len+1==st[q].len) st[cur].link=q;
    else{
      int clone=sz++;
      st[clone]=st[q];
      st[clone].len=st[p].len+1;
      while(p!=-1&&st[p].next[c]==q){
        st[p].next[c]=clone;
        p=st[p].link;
      }
      st[q].link=st[cur].link=clone;
    }
  }
  last=cur;
}

int n,d;
char s[N],a[N],b[N];

mint f[55][3005][55][2][2];
mint solve(char *s,int x,int cur,int len,int lim,int flag){
    error(flag)
  if(x>d){
    return mint(flag);
  }
  if(f[x][cur][len][lim][flag]!=-1)return f[x][cur][len][lim][flag];
  int ccur=cur,up=lim?s[x]-'0':9;
  mint ans;
  rep(i,0,up){
    if(flag)ans+=solve(s,x+1,cur,len,lim&(i==up),flag);
    else{
      while(cur&&!st[cur].next[i])
        cur=st[cur].link;
      error(s[x]-'0',st[cur].next[i])
      if(st[cur].next[i]){
        ans+=solve(s,x+1,cur,st[cur].len+1,lim&(i==up),
          flag|(st[cur].len+1>=d/2));
      }
      else ans+=solve(s,x+1,cur,0,lim&(i==up),flag|(0>=d/2));
    }
    cur=ccur;
  }
  f[x][cur][len][lim][flag]=ans;
  return ans;
}

mint work(char *s){
  rep(i1,0,51)
  rep(i2,0,3002)
  rep(i3,0,51)
  rep(i4,0,1)
  rep(i5,0,1)
  f[i1][i2][i3][i4][i5]=-1;
  return solve(s,1,0,0,1,0);
}

void Solve(){
  cin>>s+1>>a+1>>b+1;
  n=strlen(s+1),d=strlen(a+1);
  a[d]--;
  per(i,1,d)if(a[i]=='0'+-1)a[i-1]--,a[i]='9';else break;
  rep(i,1,d)error(i,b[i]-'0');
  sam_init();
  rep(i,1,n)sam_extend(s[i]-'0');
  mint ans=work(b)-work(a);
  cout<<ans<<endl;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;

const int maxn=25005;
const int mo=1000000007;

char s[1005],x[55],y[55];
int n,d,f[51][maxn][2][2][2];
int tot=1,ch[maxn][10],fail[maxn],en[maxn];

inline void insert(char *s,int len){
	int p=1;
	for(int i=0;i<len;i++){
		int c=*(s+i)-'0';
		if(!ch[p][c])ch[p][c]=++tot;
		p=ch[p][c];
	}
	en[p]=1;
}

inline void build(){
	queue<int> Q;
	for(int i=0;i<10;i++)
		if(ch[1][i])fail[ch[1][i]]=1,Q.push(ch[1][i]);
		else ch[1][i]=1;
	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];
	}
}

int main(){
	scanf("%s",s+1);
	scanf("%s%s",x+1,y+1);
	n=strlen(x+1),d=n/2;
	int len=strlen(s+1);
	for(int i=1;i<=len-d+1;i++)
		insert(s+i,d);
	build();
	f[0][1][1][1][0]=1;
	for(int i=0;i<n;i++)
		for(int j=1;j<=tot;j++)
			for(int l=0;l<2;l++)
				for(int r=0;r<2;r++)
					for(int k=0;k<2;k++)if(f[i][j][l][r][k]){
						int L=x[i+1]-'0',R=y[i+1]-'0';
						for(int t=l?L:0;t<=(r?R:9);t++){
							int v=ch[j][t];
							f[i+1][v][t==L?1:0][t==R?1:0][k||en[v]]+=f[i][j][l][r][k];
							f[i+1][v][t==L?1:0][t==R?1:0][k||en[v]]%=mo;
						}
					}
	long long ans=0;
	for(int i=1;i<=tot;i++)
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++)ans+=f[n][i][j][k][1];
	cout<<ans%mo<<endl;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;

const int maxn=25005;
const int mo=1000000007;

char s[1005],x[55],y[55];
int n,d,f[51][maxn][2][2][2];
int tot=1,ch[maxn][10],fail[maxn],en[maxn];

inline void insert(char *s,int len){
	int p=1;
	for(int i=0;i<len;i++){
		int c=*(s+i)-'0';
		if(!ch[p][c])ch[p][c]=++tot;
		p=ch[p][c];
	}
	en[p]=1;
}

inline void build(){
	queue<int> Q;
	for(int i=0;i<10;i++)
		if(ch[1][i])fail[ch[1][i]]=1,Q.push(ch[1][i]);
		else ch[1][i]=1;
	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];
	}
}

int main(){
	scanf("%s",s+1);
	scanf("%s%s",x+1,y+1);
	n=strlen(x+1),d=n/2;
	int len=strlen(s+1);
	for(int i=1;i<=len-d+1;i++)
		insert(s+i,d);
	build();
	f[0][1][1][1][0]=1;
	for(int i=0;i<n;i++)
		for(int j=1;j<=tot;j++)
			for(int l=0;l<2;l++)
				for(int r=0;r<2;r++)
					for(int k=0;k<2;k++)if(f[i][j][l][r][k]){
						int L=x[i+1]-'0',R=y[i+1]-'0';
						for(int t=l?L:0;t<=(r?R:9);t++){
							int v=ch[j][t];
							f[i+1][v][(l&&t==L)?1:0][(r&&t==R)?1:0][k||en[v]]+=f[i][j][l][r][k];
							f[i+1][v][(l&&t==L)?1:0][(r&&t==R)?1:0][k||en[v]]%=mo;
						}
					}
	long long ans=0;
	for(int i=1;i<=tot;i++)
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++)ans+=f[n][i][j][k][1];
	cout<<ans%mo<<endl;
}


#include <stdio.h>
#include <memory.h>
#include <string>
#include <vector>
#define MOD 1000000007
#define MX 25001
#define MA 10
#define MD 51
#define fs first
#define sc second
using namespace std;
string d;
int r;
vector<pair<string,int>> query;
void help(string e, int v) { // [,e)
	for (int i = 0; i < e.size(); i++) {
		string q = e;
		for (int j = i+1; j < e.size(); j++) q[j] = '?';
		for (int j = i==0; j < e[i]-'0'; j++) {
			q[i] = j+'0';
			query.push_back(make_pair(q,v));
		}
	}
}
int V, tr[MX][MA]; bool fin[MX];
int qu[MX], qs, qe, fail[MX];
int atr[MX][MA];
int c[MX][MD][2];
int C(int p, int l, bool f) {
	if (fin[p]) f = true;
	if (l == 0) return f;
	if (c[p][l][f] != -1) return c[p][l][f];
	c[p][l][f] = 0;
	for (int i = 0; i < MA; i++) {
		c[p][l][f] += C(atr[p][i],l-1,f);
		if (c[p][l][f] >= MOD) c[p][l][f] -= MOD;
	}
	return c[p][l][f];
}
int main()
{
	string s, e;
	char buf[1024];

	scanf("%s",buf); d = buf;
	scanf("%s",buf); s = buf;
	scanf("%s",buf); e = buf;

	query.push_back(make_pair(e,1));
	help(e,1); help(s,-1);

	memset(tr,-1,sizeof(tr));
	V++;
	int lim = s.size()/2;
	for (int i = 0; i+lim-1 < d.size(); i++) {
		int p = 0;
		for (int j = 0; j < lim; j++) {
			if (tr[p][d[i+j]-'0'] == -1)
				tr[p][d[i+j]-'0'] = V++;
			p = tr[p][d[i+j]-'0'];
		}
		fin[p] = true;
	}
	qu[qe++] = 0; fail[0] = -1;
	while (qs < qe) {
		int p = qu[qs++];
		for (int i = 0; i < MA; i++) {
			if (tr[p][i] == -1) {
				if (fail[p] != -1)
					atr[p][i] = atr[fail[p]][i];
			}
			else atr[p][i] = tr[p][i];
		}
		for (int i = 0; i < MA; i++) {
			int q = tr[p][i];
			if (q != -1) {
				qu[qe++] = q; fail[q] = 0;
				for (int j = fail[p]; j != -1; j = fail[j]) {
					if (tr[j][i] != -1) {
						fail[q] = tr[j][i];
						if (fin[fail[q]]) fin[q] = true;
						break;
					}
				}
			}
		}
	}

	memset(c,-1,sizeof(c));
	for (auto q : query) {
		int p = 0, l = 0; bool f = false;
		for (auto i : q.fs) {
			if (i != '?') {
				p = atr[p][i-'0'];
				if (fin[p]) f = true;
			}
			else l++;
		}
		if (q.sc == 1) {
			r += C(p,l,f);
			if (r >= MOD) r -= MOD;
		}
		else {
			r -= C(p,l,f);
			if (r < 0) r += MOD;
		}
		//printf("%s %d %d\n",q.fs.c_str(),q.sc,r);
	}
	printf("%d",r);
	return 0;
}


#include <stdio.h>
#include <memory.h>
#include <string>
#include <vector>
#define MOD 1000000007
#define MX 25001
#define MA 10
#define MD 51
#define fs first
#define sc second
using namespace std;
string d;
int r;
vector<pair<string,int>> query;
void help(string e, int v) { // [,e)
	for (int i = 0; i < e.size(); i++) {
		string q = e;
		for (int j = i+1; j < e.size(); j++) q[j] = '?';
		for (int j = i==0; j < e[i]-'0'; j++) {
			q[i] = j+'0';
			query.push_back(make_pair(q,v));
		}
	}
}
int V, tr[MX][MA]; bool fin[MX];
int qu[MX], qs, qe, fail[MX];
int atr[MX][MA];
int c[MX][MD][2];
int C(int p, int l, bool f) {
	if (l == 0) return f;
	if (c[p][l][f] != -1) return c[p][l][f] = -1;
	c[p][l][f] = 0;
	for (int i = 0; i < MA; i++) {
		int q = atr[p][i];
		if (fin[q])
			c[p][l][f] += C(q,l-1,true);
		else c[p][l][f] += C(q,l-1,f);
		if (c[p][l][f] >= MOD) c[p][l][f] -= MOD;
	}
	return c[p][l][f];
}
int main()
{
	string s, e;
	char buf[1024];

	scanf("%s",buf); d = buf;
	scanf("%s",buf); s = buf;
	scanf("%s",buf); e = buf;

	query.push_back(make_pair(e,1));
	help(e,1); help(s,-1);

	memset(tr,-1,sizeof(tr));
	V++;
	int lim = s.size()/2;
	for (int i = 0; i+lim-1 < d.size(); i++) {
		int p = 0;
		for (int j = 0; j < lim; j++) {
			if (tr[p][d[i+j]-'0'] == -1)
				tr[p][d[i+j]-'0'] = V++;
			p = tr[p][d[i+j]-'0'];
		}
		fin[p] = true;
	}
	qu[qe++] = 0; fail[0] = -1;
	for (int i = 0; i < MA; i++) {
		if (tr[0][i] != -1)
			atr[0][i] = tr[0][i];
	}
	while (qs < qe) {
		int p = qu[qs++];
		for (int i = 0; i < MA; i++) {
			int q = tr[p][i];
			if (q != -1) {
				qu[qe++] = q; fail[q] = -1;
				for (int j = fail[p]; j != -1; j = fail[j]) {
					if (tr[j][i] != -1) {
						fail[q] = tr[j][i];
						break;
					}
				}
				for (int j = 0; j < MA; j++) {
					for (int k = p; k != -1; k = fail[k]) {
						if (tr[k][j] != -1) {
							atr[q][j] = tr[k][j];
							break;
						}
					}
				}
			}
		}
	}

	memset(c,-1,sizeof(c));
	for (auto q : query) {
		int p = 0, l = 0; bool f = false;
		for (auto i : q.fs) {
			if (i != '?') {
				p = atr[p][i-'0'];
				if (fin[p]) f = true;
			}
			else l++;
		}
		if (q.sc == 1) {
			r += C(p,l,f);
			if (r >= MOD) r -= MOD;
		}
		else {
			r -= C(p,l,f);
			if (r >= MOD) r -= MOD;
		}
		//printf("%s %d %d\n",q.fs.c_str(),q.sc,r);
	}
	printf("%d",r);
	return 0;
}


#include <stdio.h>
#include <memory.h>
#include <string>
#include <vector>
#define MOD 1000000007
#define MX 25001
#define MA 10
#define MD 51
#define fs first
#define sc second
using namespace std;
string d;
int r;
vector<pair<string,int>> query;
void help(string e, int v) { // [,e)
	for (int i = 0; i < e.size(); i++) {
		string q = e;
		for (int j = i+1; j < e.size(); j++) q[j] = '?';
		for (int j = i==0; j < e[i]-'0'; j++) {
			q[i] = j+'0';
			query.push_back(make_pair(q,v));
		}
	}
}
int V, tr[MX][MA]; bool fin[MX];
int qu[MX], qs, qe, fail[MX];
int atr[MX][MA];
int c[MX][MD][2];
int C(int p, int l, bool f) {
	if (fin[p]) f = true;
	if (l == 0) return f;
	if (c[p][l][f] != -1) return c[p][l][f];
	c[p][l][f] = 0;
	for (int i = 0; i < MA; i++) {
		c[p][l][f] += C(atr[p][i],l-1,f);
		if (c[p][l][f] >= MOD) c[p][l][f] -= MOD;
	}
	return c[p][l][f];
}
int main()
{
	string s, e;
	char buf[1024];

	scanf("%s",buf); d = buf;
	scanf("%s",buf); s = buf;
	scanf("%s",buf); e = buf;

	query.push_back(make_pair(e,1));
	help(e,1); help(s,-1);

	memset(tr,-1,sizeof(tr));
	V++;
	int lim = s.size()/2;
	for (int i = 0; i+lim-1 < d.size(); i++) {
		int p = 0;
		for (int j = 0; j < lim; j++) {
			if (tr[p][d[i+j]-'0'] == -1)
				tr[p][d[i+j]-'0'] = V++;
			p = tr[p][d[i+j]-'0'];
		}
		fin[p] = true;
	}
	qu[qe++] = 0; fail[0] = -1;
	while (qs < qe) {
		int p = qu[qs++];
		for (int i = 0; i < MA; i++) {
			int q = tr[p][i];
			if (q != -1) {
				qu[qe++] = q; fail[q] = 0;
				for (int j = fail[p]; j != -1; j = fail[j]) {
					if (tr[j][i] != -1) {
						fail[q] = tr[j][i];
						if (fin[fail[q]]) fin[q] = true;
						break;
					}
				}
			}
		}
	}
	for (int i = 0; i < V; i++) {
		for (int j = 0; j < MA; j++) {
			if (tr[i][j] == -1) {
				if (fail[i] != -1)
					atr[i][j] = atr[fail[i]][j];
				else atr[i][j] = 0;
			}
			else atr[i][j] = tr[i][j];
		}
	}

	memset(c,-1,sizeof(c));
	for (auto q : query) {
		int p = 0, l = 0; bool f = false;
		for (auto i : q.fs) {
			if (i != '?') {
				p = atr[p][i-'0'];
				if (fin[p]) f = true;
			}
			else l++;
		}
		if (q.sc == 1) {
			r += C(p,l,f);
			if (r >= MOD) r -= MOD;
		}
		else {
			r -= C(p,l,f);
			if (r < 0) r += MOD;
		}
		//printf("%s %d %d\n",q.fs.c_str(),q.sc,r);
	}
	printf("%d",r);
	return 0;
}


#include <stdio.h>
#include <memory.h>
#include <string>
#include <vector>
#define MOD 1000000007
#define MX 25001
#define MA 10
#define MD 51
#define fs first
#define sc second
using namespace std;
string d;
int r;
vector<pair<string,int>> query;
void help(string e, int v) { // [,e)
	for (int i = 0; i < e.size(); i++) {
		string q = e;
		for (int j = i+1; j < e.size(); j++) q[j] = '?';
		for (int j = i==0; j < e[i]-'0'; j++) {
			q[i] = j+'0';
			query.push_back(make_pair(q,v));
		}
	}
}
int V, tr[MX][MA]; bool fin[MX];
int qu[MX], qs, qe, fail[MX];
int atr[MX][MA];
int c[MX][MD][2];
int C(int p, int l, bool f) {
	if (fin[p]) f = true;
	if (l == 0) return f;
	if (c[p][l][f] != -1) return c[p][l][f];
	c[p][l][f] = 0;
	for (int i = 0; i < MA; i++) {
		c[p][l][f] += C(atr[p][i],l-1,f);
		if (c[p][l][f] >= MOD) c[p][l][f] -= MOD;
	}
	return c[p][l][f];
}
int main()
{
	string s, e;
	char buf[1024];

	scanf("%s",buf); d = buf;
	scanf("%s",buf); s = buf;
	scanf("%s",buf); e = buf;

	query.push_back(make_pair(e,1));
	help(e,1); help(s,-1);

	memset(tr,-1,sizeof(tr));
	V++;
	int lim = s.size()/2;
	for (int i = 0; i+lim-1 < d.size(); i++) {
		int p = 0;
		for (int j = 0; j < lim; j++) {
			if (tr[p][d[i+j]-'0'] == -1)
				tr[p][d[i+j]-'0'] = V++;
			p = tr[p][d[i+j]-'0'];
		}
		fin[p] = true;
	}
	qu[qe++] = 0; fail[0] = -1;
	while (qs < qe) {
		int p = qu[qs++];
		for (int i = 0; i < MA; i++) {
			int q = tr[p][i];
			if (q != -1) {
				qu[qe++] = q; fail[q] = 0;
				for (int j = fail[p]; j != -1; j = fail[j]) {
					if (tr[j][i] != -1) {
						fail[q] = tr[j][i];
						if (fin[fail[q]]) fin[q] = true;
						break;
					}
				}
			}
		}
	}
	for (int i = 0; i < V; i++) {
		for (int j = 0; j < MA; j++) {
			for (int k = i; k != -1; k = fail[k]) {
				if (tr[k][j] != -1) {
					atr[i][j] = tr[k][j];
					break;
				}
			}
		}
	}

	memset(c,-1,sizeof(c));
	for (auto q : query) {
		int p = 0, l = 0; bool f = false;
		for (auto i : q.fs) {
			if (i != '?') {
				p = atr[p][i-'0'];
				if (fin[p]) f = true;
			}
			else l++;
		}
		if (q.sc == 1) {
			r += C(p,l,f);
			if (r >= MOD) r -= MOD;
		}
		else {
			r -= C(p,l,f);
			if (r < 0) r += MOD;
		}
		//printf("%s %d %d\n",q.fs.c_str(),q.sc,r);
	}
	printf("%d",r);
	return 0;
}


#include <stdio.h>
#include <memory.h>
#include <string>
#include <vector>
#define MOD 1000000007
#define MX 25001
#define MA 10
#define MD 51
#define fs first
#define sc second
using namespace std;
string d;
int r;
vector<pair<string,int>> query;
void help(string e, int v) { // [,e)
	for (int i = 0; i < e.size(); i++) {
		string q = e;
		for (int j = i+1; j < e.size(); j++) q[j] = '?';
		for (int j = i==0; j < e[i]-'0'; j++) {
			q[i] = j+'0';
			query.push_back(make_pair(q,v));
		}
	}
}
int V, tr[MX][MA]; bool fin[MX];
int qu[MX], qs, qe, fail[MX];
int atr[MX][MA];
int c[MX][MD][2];
int C(int p, int l, bool f) {
	if (l == 0) return f;
	if (c[p][l][f] != -1) return c[p][l][f];
	c[p][l][f] = 0;
	for (int i = 0; i < MA; i++) {
		int q = atr[p][i];
		if (fin[q])
			c[p][l][f] += C(q,l-1,true);
		else c[p][l][f] += C(q,l-1,f);
		if (c[p][l][f] >= MOD) c[p][l][f] -= MOD;
	}
	return c[p][l][f];
}
int main()
{
	string s, e;
	char buf[1024];

	scanf("%s",buf); d = buf;
	scanf("%s",buf); s = buf;
	scanf("%s",buf); e = buf;

	query.push_back(make_pair(e,1));
	help(e,1); help(s,-1);

	memset(tr,-1,sizeof(tr));
	V++;
	int lim = s.size()/2;
	for (int i = 0; i+lim-1 < d.size(); i++) {
		int p = 0;
		for (int j = 0; j < lim; j++) {
			if (tr[p][d[i+j]-'0'] == -1)
				tr[p][d[i+j]-'0'] = V++;
			p = tr[p][d[i+j]-'0'];
		}
		fin[p] = true;
	}
	qu[qe++] = 0; fail[0] = -1;
	while (qs < qe) {
		int p = qu[qs++];
		for (int i = 0; i < MA; i++) {
			int q = tr[p][i];
			if (q != -1) {
				qu[qe++] = q; fail[q] = -1;
				for (int j = fail[p]; j != -1; j = fail[j]) {
					if (tr[j][i] != -1) {
						fail[q] = tr[j][i];
						break;
					}
				}
			}
		}
	}
	for (int i = 0; i < V; i++) {
		for (int j = 0; j < MA; j++) {
			for (int k = i; k != -1; k = fail[k]) {
				if (tr[k][j] != -1) {
					atr[i][j] = tr[k][j];
					break;
				}
			}
		}
	}

	memset(c,-1,sizeof(c));
	for (auto q : query) {
		int p = 0, l = 0; bool f = false;
		for (auto i : q.fs) {
			if (i != '?') {
				p = atr[p][i-'0'];
				if (fin[p]) f = true;
			}
			else l++;
		}
		if (q.sc == 1) {
			r += C(p,l,f);
			if (r >= MOD) r -= MOD;
		}
		else {
			r -= C(p,l,f);
			if (r < 0) r += MOD;
		}
		//printf("%s %d %d\n",q.fs.c_str(),q.sc,r);
	}
	printf("%d",r);
	return 0;
}


#include <stdio.h>
#include <memory.h>
#include <string>
#include <vector>
#define MOD 1000000007
#define MX 25001
#define MA 10
#define MD 51
#define fs first
#define sc second
using namespace std;
string d;
int r;
vector<pair<string,int>> query;
void help(string e, int v) { // [,e)
	for (int i = 0; i < e.size(); i++) {
		string q = e;
		for (int j = i+1; j < e.size(); j++) q[j] = '?';
		for (int j = i==0; j < e[i]-'0'; j++) {
			q[i] = j+'0';
			query.push_back(make_pair(q,v));
		}
	}
}
int V, tr[MX][MA]; bool fin[MX];
int qu[MX], qs, qe, fail[MX];
int atr[MX][MA];
int c[MX][MD][2];
int C(int p, int l, bool f) {
	if (l == 0) return f;
	if (c[p][l][f] != -1) return c[p][l][f] = -1;
	c[p][l][f] = 0;
	for (int i = 0; i < MA; i++) {
		int q = atr[p][i];
		if (fin[q])
			c[p][l][f] += C(q,l-1,true);
		else c[p][l][f] += C(q,l-1,f);
		if (c[p][l][f] >= MOD) c[p][l][f] -= MOD;
	}
	return c[p][l][f];
}
int main()
{
	string s, e;
	char buf[1024];

	scanf("%s",buf); d = buf;
	scanf("%s",buf); s = buf;
	scanf("%s",buf); e = buf;

	query.push_back(make_pair(e,1));
	help(e,1); help(s,-1);

	memset(tr,-1,sizeof(tr));
	V++;
	int lim = s.size()/2;
	for (int i = 0; i+lim-1 < d.size(); i++) {
		int p = 0;
		for (int j = 0; j < lim; j++) {
			if (tr[p][d[i+j]-'0'] == -1)
				tr[p][d[i+j]-'0'] = V++;
			p = tr[p][d[i+j]-'0'];
		}
		fin[p] = true;
	}
	qu[qe++] = 0; fail[0] = -1;
	for (int i = 0; i < MA; i++) {
		if (tr[0][i] != -1)
			atr[0][i] = tr[0][i];
	}
	while (qs < qe) {
		int p = qu[qs++];
		for (int i = 0; i < MA; i++) {
			int q = tr[p][i];
			if (q != -1) {
				qu[qe++] = q; fail[q] = -1;
				for (int j = fail[p]; j != -1; j = fail[j]) {
					if (tr[j][i] != -1) {
						fail[q] = tr[j][i];
						break;
					}
				}
				for (int j = 0; j < MA; j++) {
					for (int k = p; k != -1; k = fail[k]) {
						if (tr[k][j] != -1) {
							atr[q][j] = tr[k][j];
							break;
						}
					}
				}
			}
		}
	}

	memset(c,-1,sizeof(c));
	for (auto q : query) {
		int p = 0, l = 0; bool f = false;
		for (auto i : q.fs) {
			if (i != '?') {
				p = atr[p][i-'0'];
				if (fin[p]) f = true;
			}
			else l++;
		}
		if (q.sc == 1) {
			r += C(p,l,f);
			if (r >= MOD) r -= MOD;
		}
		else {
			r -= C(p,l,f);
			if (r < 0) r += MOD;
		}
		//printf("%s %d %d\n",q.fs.c_str(),q.sc,r);
	}
	printf("%d",r);
	return 0;
}


//gzhffIThh
#include<bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout);

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;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	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 = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	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);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 1010, D = 51, P = 1000000007;
int n, d;
char s[N], x[N], y[N];
ll p[N][2], f[D][N * D][2];
struct ACAM {
	int rt, si, fail[N * D], to[N * D][11], ed[N * D];
	inline int tn(int x, int y) {
		return to[x][y] ? to[x][y] : tn(fail[x], y);
	}
	inline void build() {
		si = rt = 1;
		int len = d / 2;
		for (int i = 1; i + len - 1 <= n; i++){
			int p = rt;
			for (int j = i; j <= len + i - 1; j++) {
				int c = s[j] - '0';
				if(!to[p][c]) to[p][c] = ++si;
				p = to[p][c];
			}
			ed[p] = 1;
		}
	}
	inline void gefi() {
		queue<int> q;
		for (int i = 0; i < 10; i++) to[0][i] = rt;
		q.push(rt);
		while(!q.empty()) {
			int u = q.front(); q.pop();
			for (int i = 0; i < 10; i++) {
				if(to[u][i]) {
					// fail[to[u][i]] = tn(fail[u], i);
					// q.push(to[u][i]);
					fail[to[u][i]]=to[fail[u]][i];
					q.push(to[u][i]);
				}else {
					to[u][i] = to[fail[u]][i];
				}
			}
		}
	}
}acam;
ll calc(char *str) {
	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] = p[i + 1][0] * (str[i] - '0') + p[i + 1][1];
	}
	ll ans = 0;
	for (int i = 0; i <= d; i++) {
		for (int j = 0; j <= acam.si; 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 <= acam.si; j++) {
			if(!acam.ed[j]) {
				for (int k = 0; k < 10; k++) {
					int o = acam.to[j][k];
					f[i + 1][o][0] = (f[i][j][0] + f[i + 1][o][0]) % P;
					if(k < str[i + 1] - '0') f[i + 1][o][0] = (f[i + 1][o][0] + f[i][j][1]) % P;
					if(k == str[i + 1] - '0') f[i + 1][o][1] = (f[i + 1][o][1] + f[i][j][1]) % P;
				}
			}
		}
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 1; j <= acam.si; j++) {
			if(acam.ed[j]) {
				ans = (ans + (f[i][j][0] * p[i + 1][0]) % P + (f[i][j][1] * p[i + 1][1]) % P) % P;
			}
		}
	}
	return ans;
}

int main() {
	//fl("E");
	rds(s, n); rds(x, d); rds(y, d);
	acam.build(); acam.gefi();
	int tmp = d;
	while(x[tmp] == '0') x[tmp--] = '9';
	--x[tmp];
	// debug("%s %s", x + 1, y + 1);
	print(calc(y) - calc(x));
	return 0;
}


//gzhffIThh
#include<bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout);

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;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	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 = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	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);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 1010, D = 55;
const ll P = 1000000007;
int n, d;
char s[N], x[N], y[N];
ll p[N][2], f[D][N * D][2];
struct ACAM {
	int rt, si, fail[N * D], to[N * D][12], ed[N * D];
	inline void build() {
		si = rt = 1;
		int len = d / 2;
		for (int i = 1; i + len - 1 <= n; i++){
			int p = rt;
			for (int j = i; j <= len + i - 1; j++) {
				int c = s[j] - '0';
				if(!to[p][c]) to[p][c] = ++si;
				p = to[p][c];
			}
			ed[p] = 1;
		}
	}
	inline void gefi() {
		queue<int> q;
		for (int i = 0; i < 10; i++) to[0][i] = rt;
		q.push(rt);
		while(!q.empty()) {
			int u = q.front(); q.pop();
			for (int i = 0; i < 10; i++) {
				if(to[u][i]) {
					fail[to[u][i]]=to[fail[u]][i];
					q.push(to[u][i]);
				}else {
					to[u][i] = to[fail[u]][i];
				}
			}
		}
	}
}acam;
ll calc(char *str) {
	p[d + 1][0] = p[d + 1][1] = 1;
	for (int i = d; i; i--) {
		p[i][0] = (p[i + 1][0] * 10) % P;
		p[i][1] = ((p[i + 1][0] * (str[i] - '0')) % P + p[i + 1][1]) % P;
	}
	ll ans = 0;
	for (int i = 0; i <= d; i++) {
		for (int j = 0; j <= acam.si; 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 <= acam.si; j++) {
			if(!acam.ed[j]) {
				for (int k = 0; k < 10; k++) {
					int o = acam.to[j][k];
					f[i + 1][o][0] = (f[i][j][0] + f[i + 1][o][0]) % P;
					if(k < str[i + 1] - '0') f[i + 1][o][0] = (f[i + 1][o][0] + f[i][j][1]) % P;
					if(k == str[i + 1] - '0') f[i + 1][o][1] = (f[i + 1][o][1] + f[i][j][1]) % P;
				}
			}
		}
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 1; j <= acam.si; j++) {
			if(acam.ed[j]) {
				ans = (ans + (f[i][j][0] * p[i + 1][0]) % P + (f[i][j][1] * p[i + 1][1]) % P) % P;
			}
		}
	}
	return ans % P;
}

int main() {
//	fl("E");
	rds(s, n); rds(x, d); rds(y, d);
	acam.build(); acam.gefi();
	int tmp = d;
	while(x[tmp] == '0') x[tmp--] = '9';
	--x[tmp];
	// debug("%s %s", x + 1, y + 1);
	print((calc(y) - calc(x) + P) % P);
	return 0;
}


//gzhffIThh
#include<bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout);

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;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	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 = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	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);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 1010, D = 51, P = 1000000007;
int n, d;
char s[N], x[N], y[N];
ll p[N][2], f[D][N * D][2];
struct ACAM {
	int rt, si, fail[N * D], to[N * D][11], ed[N * D];
	inline int tn(int x, int y) {
		return to[x][y] ? to[x][y] : tn(fail[x], y);
	}
	inline void build() {
		si = rt = 1;
		int len = d / 2;
		for (int i = 1; i + len - 1 <= n; i++){
			int p = rt;
			for (int j = i; j <= len + i - 1; j++) {
				int c = s[j] - '0';
				if(!to[p][c]) to[p][c] = ++si;
				p = to[p][c];
			}
			ed[p] = 1;
		}
	}
	inline void gefi() {
		queue<int> q;
		for (int i = 0; i < 10; i++) to[0][i] = rt;
		q.push(rt);
		while(!q.empty()) {
			int u = q.front(); q.pop();
			for (int i = 0; i < 10; i++) {
				if(to[u][i]) {
					// fail[to[u][i]] = tn(fail[u], i);
					// q.push(to[u][i]);
					fail[to[u][i]]=to[fail[u]][i];
					q.push(to[u][i]);
				}else {
					to[u][i] = to[fail[u]][i];
				}
			}
		}
	}
}acam;
ll calc(char *str) {
	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] = p[i + 1][0] * (str[i] - '0') + p[i + 1][1];
	}
	ll ans = 0;
	for (int i = 0; i <= d; i++) {
		for (int j = 0; j <= acam.si; 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 <= acam.si; j++) {
			if(!acam.ed[j]) {
				for (int k = 0; k < 10; k++) {
					int o = acam.to[j][k];
					f[i + 1][o][0] = (f[i][j][0] + f[i + 1][o][0]) % P;
					if(k < str[i + 1] - '0') f[i + 1][o][0] = (f[i + 1][o][0] + f[i][j][1]) % P;
					if(k == str[i + 1] - '0') f[i + 1][o][1] = (f[i + 1][o][1] + f[i][j][1]) % P;
				}
			}
		}
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 1; j <= acam.si; j++) {
			if(acam.ed[j]) {
				ans = (ans + (f[i][j][0] * p[i + 1][0]) % P + (f[i][j][1] * p[i + 1][1]) % P) % P;
			}
		}
	}
	return ans;
}

int main() {
	fl("E");
	rds(s, n); rds(x, d); rds(y, d);
	acam.build(); acam.gefi();
	int tmp = d;
	while(x[tmp] == '0') x[tmp--] = '9';
	--x[tmp];
	// debug("%s %s", x + 1, y + 1);
	print(calc(y) - calc(x));
	return 0;
}


//gzhffIThh
#include<bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout);

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;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	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 = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	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);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 1010, D = 51, P = 1000000007;
int n, d;
char s[N], x[N], y[N];
ll p[N][2], f[D][N * D][2];
struct ACAM {
	int rt, si, fail[N * D], to[N * D][11], ed[N * D];
	inline int tn(int x, int y) {
		return to[x][y] ? to[x][y] : tn(fail[x], y);
	}
	inline void build() {
		si = rt = 1;
		int len = d / 2;
		for (int i = 1; i + len - 1 <= n; i++){
			int p = rt;
			for (int j = i; j <= len + i - 1; j++) {
				int c = s[j] - '0';
				if(!to[p][c]) to[p][c] = ++si;
				p = to[p][c];
			}
			ed[p] = 1;
		}
	}
	inline void gefi() {
		queue<int> q;
		for (int i = 0; i < 10; i++) to[0][i] = rt;
		q.push(rt);
		while(!q.empty()) {
			int u = q.front(); q.pop();
			for (int i = 0; i < 10; i++) {
				if(to[u][i]) {
					// fail[to[u][i]] = tn(fail[u], i);
					// q.push(to[u][i]);
					fail[to[u][i]]=to[fail[u]][i];
					q.push(to[u][i]);
				}else {
					to[u][i] = to[fail[u]][i];
				}
			}
		}
	}
}acam;
ll calc(char *str) {
	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] = p[i + 1][0] * (str[i] - '0') + p[i + 1][1];
	}
	ll ans = 0;
	for (int i = 0; i <= d; i++) {
		for (int j = 0; j <= acam.si; 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 <= acam.si; j++) {
			if(!acam.ed[j]) {
				for (int k = 0; k < 10; k++) {
					int o = acam.to[j][k];
					f[i + 1][o][0] = (f[i][j][0] + f[i + 1][o][0]) % P;
					if(k < str[i + 1] - '0') f[i + 1][o][0] = (f[i + 1][o][0] + f[i][j][1]) % P;
					if(k == str[i + 1] - '0') f[i + 1][o][1] = (f[i + 1][o][1] + f[i][j][1]) % P;
				}
			}
		}
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 1; j <= acam.si; j++) {
			if(acam.ed[j]) {
				ans = (ans + (f[i][j][0] * p[i + 1][0]) % P + (f[i][j][1] * p[i + 1][1]) % P) % P;
			}
		}
	}
	return ans;
}

int main() {
// 	fl("E");
	rds(s, n); rds(x, d); rds(y, d);
	acam.build(); acam.gefi();
	int tmp = d;
	while(x[tmp] == '0') x[tmp--] = '9';
	--x[tmp];
	// debug("%s %s", x + 1, y + 1);
	print(calc(y) - calc(x));
	return 0;
}


//gzhffIThh
#include<bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair//gzhffIThh
#include<bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout);

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;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	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 = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	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);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 1010, D = 51, P = 1000000007;
int n, d;
char s[N], x[N], y[N];
ll p[N][2], f[D][N * D][2];
struct ACAM {
	int rt, si, fail[N * D], to[N * D][11], ed[N * D];
	inline int tn(int x, int y) {
		return to[x][y] ? to[x][y] : tn(fail[x], y);
	}
	inline void build() {
		si = rt = 1;
		int len = d / 2;
		for (int i = 1; i + len - 1 <= n; i++){
			int p = rt;
			for (int j = i; j <= len + i - 1; j++) {
				int c = s[j] - '0';
				if(!to[p][c]) to[p][c] = ++si;
				p = to[p][c];
			}
			ed[p] = 1;
		}
	}
	inline void gefi() {
		queue<int> q;
		for (int i = 0; i < 10; i++) to[0][i] = rt;
		q.push(rt);
		while(!q.empty()) {
			int u = q.front(); q.pop();
			for (int i = 0; i < 10; i++) {
				if(to[u][i]) {
					// fail[to[u][i]] = tn(fail[u], i);
					// q.push(to[u][i]);
					fail[to[u][i]]=to[fail[u]][i];
					q.push(to[u][i]);
				}else {
					to[u][i] = to[fail[u]][i];
				}
			}
		}
	}
}acam;
ll calc(char *str) {
	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] = p[i + 1][0] * (str[i] - '0') + p[i + 1][1];
	}
	ll ans = 0;
	for (int i = 0; i <= d; i++) {
		for (int j = 0; j <= acam.si; 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 <= acam.si; j++) {
			if(!acam.ed[j]) {
				for (int k = 0; k < 10; k++) {
					int o = acam.to[j][k];
					f[i + 1][o][0] = (f[i][j][0] + f[i + 1][o][0]) % P;
					if(k < str[i + 1] - '0') f[i + 1][o][0] = (f[i + 1][o][0] + f[i][j][1]) % P;
					if(k == str[i + 1] - '0') f[i + 1][o][1] = (f[i + 1][o][1] + f[i][j][1]) % P;
				}
			}
		}
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 1; j <= acam.si; j++) {
			if(acam.ed[j]) {
				ans = (ans + (f[i][j][0] * p[i + 1][0]) % P + (f[i][j][1] * p[i + 1][1]) % P) % P;
			}
		}
	}
	return ans;
}

int main() {
	//fl("E");
	rds(s, n); rds(x, d); rds(y, d);
	acam.build(); acam.gefi();
	int tmp = d;
	while(x[tmp] == '0') x[tmp--] = '9';
	--x[tmp];
	// debug("%s %s", x + 1, y + 1);
	print((calc(y) - calc(x) + P) % P);
	return 0;
}

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout);

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;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	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 = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	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);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 1010, D = 51, P = 1000000007;
int n, d;
char s[N], x[N], y[N];
ll p[N][2], f[D][N * D][2];
struct ACAM {
	int rt, si, fail[N * D], to[N * D][11], ed[N * D];
	inline int tn(int x, int y) {
		return to[x][y] ? to[x][y] : tn(fail[x], y);
	}
	inline void build() {
		si = rt = 1;
		int len = d / 2;
		for (int i = 1; i + len - 1 <= n; i++){
			int p = rt;
			for (int j = i; j <= len + i - 1; j++) {
				int c = s[j] - '0';
				if(!to[p][c]) to[p][c] = ++si;
				p = to[p][c];
			}
			ed[p] = 1;
		}
	}
	inline void gefi() {
		queue<int> q;
		for (int i = 0; i < 10; i++) to[0][i] = rt;
		q.push(rt);
		while(!q.empty()) {
			int u = q.front(); q.pop();
			for (int i = 0; i < 10; i++) {
				if(to[u][i]) {
					// fail[to[u][i]] = tn(fail[u], i);
					// q.push(to[u][i]);
					fail[to[u][i]]=to[fail[u]][i];
					q.push(to[u][i]);
				}else {
					to[u][i] = to[fail[u]][i];
				}
			}
		}
	}
}acam;
ll calc(char *str) {
	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] = p[i + 1][0] * (str[i] - '0') + p[i + 1][1];
	}
	ll ans = 0;
	for (int i = 0; i <= d; i++) {
		for (int j = 0; j <= acam.si; 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 <= acam.si; j++) {
			if(!acam.ed[j]) {
				for (int k = 0; k < 10; k++) {
					int o = acam.to[j][k];
					f[i + 1][o][0] = (f[i][j][0] + f[i + 1][o][0]) % P;
					if(k < str[i + 1] - '0') f[i + 1][o][0] = (f[i + 1][o][0] + f[i][j][1]) % P;
					if(k == str[i + 1] - '0') f[i + 1][o][1] = (f[i + 1][o][1] + f[i][j][1]) % P;
				}
			}
		}
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 1; j <= acam.si; j++) {
			if(acam.ed[j]) {
				ans = (ans + (f[i][j][0] * p[i + 1][0]) % P + (f[i][j][1] * p[i + 1][1]) % P) % P;
			}
		}
	}
	return ans;
}

int main() {
	//fl("E");
	rds(s, n); rds(x, d); rds(y, d);
	acam.build(); acam.gefi();
	int tmp = d;
	while(x[tmp] == '0') x[tmp--] = '9';
	--x[tmp];
	// debug("%s %s", x + 1, y + 1);
	print(calc(y) - calc(x));
	return 0;
}


//gzhffIThh
#include<bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout);

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;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	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 = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	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);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 1010, D = 51, P = 1000000007;
int n, d;
char s[N], x[N], y[N];
ll p[N][2], f[D][N * D][2];
struct ACAM {
	int rt, si, fail[N * D], to[N * D][11], ed[N * D];
	inline int tn(int x, int y) {
		return to[x][y] ? to[x][y] : tn(fail[x], y);
	}
	inline void build() {
		si = rt = 1;
		int len = d / 2;
		for (int i = 1; i + len - 1 <= n; i++){
			int p = rt;
			for (int j = i; j <= len + i - 1; j++) {
				int c = s[j] - '0';
				if(!to[p][c]) to[p][c] = ++si;
				p = to[p][c];
			}
			ed[p] = 1;
		}
	}
	inline void gefi() {
		queue<int> q;
		for (int i = 0; i < 10; i++) to[0][i] = rt;
		q.push(rt);
		while(!q.empty()) {
			int u = q.front(); q.pop();
			for (int i = 0; i < 10; i++) {
				if(to[u][i]) {
					// fail[to[u][i]] = tn(fail[u], i);
					// q.push(to[u][i]);
					fail[to[u][i]]=to[fail[u]][i];
					q.push(to[u][i]);
				}else {
					to[u][i] = to[fail[u]][i];
				}
			}
		}
	}
}acam;
ll calc(char *str) {
	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] = p[i + 1][0] * (str[i] - '0') + p[i + 1][1];
	}
	ll ans = 0;
	for (int i = 0; i <= d; i++) {
		for (int j = 0; j <= acam.si; 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 <= acam.si; j++) {
			if(!acam.ed[j]) {
				for (int k = 0; k < 10; k++) {
					int o = acam.to[j][k];
					f[i + 1][o][0] = (f[i][j][0] + f[i + 1][o][0]) % P;
					if(k < str[i + 1] - '0') f[i + 1][o][0] = (f[i + 1][o][0] + f[i][j][1]) % P;
					if(k == str[i + 1] - '0') f[i + 1][o][1] = (f[i + 1][o][1] + f[i][j][1]) % P;
				}
			}
		}
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 1; j <= acam.si; j++) {
			if(acam.ed[j]) {
				ans = (ans + (f[i][j][0] * p[i + 1][0]) % P + (f[i][j][1] * p[i + 1][1]) % P) % P;
			}
		}
	}
	return ans;
}

int main() {
	//fl("E");
	rds(s, n); rds(x, d); rds(y, d);
	acam.build(); acam.gefi();
	int tmp = d;
	while(x[tmp] == '0') x[tmp--] = '9';
	--x[tmp];
	// debug("%s %s", x + 1, y + 1);
	print((calc(y) - calc(x) + P) % P);
	return 0;
}


//gzhffIThh
#include<bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout);

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;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	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 = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	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);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 1010, D = 51, P = 1000000007;
int n, d;
char s[N], x[N], y[N];
ll p[N][2], f[D][N * D][2];
struct ACAM {
	int rt, si, fail[N * D], to[N * D][11], ed[N * D];
	inline int tn(int x, int y) {
		return to[x][y] ? to[x][y] : tn(fail[x], y);
	}
	inline void build() {
		si = rt = 1;
		int len = d / 2;
		for (int i = 1; i + len - 1 <= n; i++){
			int p = rt;
			for (int j = i; j <= len + i - 1; j++) {
				int c = s[j] - '0';
				if(!to[p][c]) to[p][c] = ++si;
				p = to[p][c];
			}
			ed[p] = 1;
		}
	}
	inline void gefi() {
		queue<int> q;
		for (int i = 0; i < 10; i++) to[0][i] = rt;
		q.push(rt);
		while(!q.empty()) {
			int u = q.front(); q.pop();
			for (int i = 0; i < 10; i++) {
				if(to[u][i]) {
					// fail[to[u][i]] = tn(fail[u], i);
					// q.push(to[u][i]);
					fail[to[u][i]]=to[fail[u]][i];
					q.push(to[u][i]);
				}else {
					to[u][i] = to[fail[u]][i];
				}
			}
		}
	}
}acam;
ll calc(char *str) {
	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] = p[i + 1][0] * (str[i] - '0') + p[i + 1][1];
	}
	ll ans = 0;
	for (int i = 0; i <= d; i++) {
		for (int j = 0; j <= acam.si; 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 <= acam.si; j++) {
			if(!acam.ed[j]) {
				for (int k = 0; k < 10; k++) {
					int o = acam.to[j][k];
					f[i + 1][o][0] = (f[i][j][0] + f[i + 1][o][0]) % P;
					if(k < str[i + 1] - '0') f[i + 1][o][0] = (f[i + 1][o][0] + f[i][j][1]) % P;
					if(k == str[i + 1] - '0') f[i + 1][o][1] = (f[i + 1][o][1] + f[i][j][1]) % P;
				}
			}
		}
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 1; j <= acam.si; j++) {
			if(acam.ed[j]) {
				ans = (ans + (f[i][j][0] * p[i + 1][0]) % P + (f[i][j][1] * p[i + 1][1]) % P) % P;
			}
		}
	}
	return ans;
}

int main() {
	fl("E");
	rds(s, n); rds(x, d); rds(y, d);
	acam.build(); acam.gefi();
	int tmp = d;
	while(x[tmp] == '0') x[tmp--] = '9';
	--x[tmp];
	// debug("%s %s", x + 1, y + 1);
	print((calc(y) - calc(x) + P) % P);
	return 0;
}


//gzhffIThh
#include<bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout);

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;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	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 = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	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);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 1010, D = 55;
const ll P = 1000000007;
int n, d;
char s[N], x[N], y[N];
ll p[N][2], f[D][N * D][2];
struct ACAM {
	int rt, si, fail[N * D], to[N * D][12], ed[N * D];
	inline void build() {
		si = rt = 1;
		int len = d / 2;
		for (int i = 1; i + len - 1 <= n; i++){
			int p = rt;
			for (int j = i; j <= len + i - 1; j++) {
				int c = s[j] - '0';
				if(!to[p][c]) to[p][c] = ++si;
				p = to[p][c];
			}
			ed[p] = 1;
		}
	}
	inline void gefi() {
		queue<int> q;
		for (int i = 0; i < 10; i++) to[0][i] = rt;
		q.push(rt);
		while(!q.empty()) {
			int u = q.front(); q.pop();
			for (int i = 0; i < 10; i++) {
				if(to[u][i]) {
					fail[to[u][i]]=to[fail[u]][i];
					q.push(to[u][i]);
				}else {
					to[u][i] = to[fail[u]][i];
				}
			}
		}
	}
}acam;
ll calc(char *str) {
	p[d + 1][0] = p[d + 1][1] = 1;
	for (int i = d; i; i--) {
		p[i][0] = (p[i + 1][0] * 10) % P;
		p[i][1] = ((p[i + 1][0] * (str[i] - '0')) % P + p[i + 1][1]) % P;
	}
	ll ans = 0;
	for (int i = 0; i <= d; i++) {
		for (int j = 0; j <= acam.si; 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 <= acam.si; j++) {
			if(!acam.ed[j]) {
				for (int k = 0; k < 10; k++) {
					int o = acam.to[j][k];
					f[i + 1][o][0] = (f[i][j][0] + f[i + 1][o][0]) % P;
					if(k < str[i + 1] - '0') f[i + 1][o][0] = (f[i + 1][o][0] + f[i][j][1]) % P;
					if(k == str[i + 1] - '0') f[i + 1][o][1] = (f[i + 1][o][1] + f[i][j][1]) % P;
				}
			}
		}
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 1; j <= acam.si; j++) {
			if(acam.ed[j]) {
				ans = (ans + (f[i][j][0] * p[i + 1][0]) % P + (f[i][j][1] * p[i + 1][1]) % P) % P;
			}
		}
	}
	return ans % P;
}

int main() {
// 	fl("E");
	rds(s, n); rds(x, d); rds(y, d);
	acam.build(); acam.gefi();
	int tmp = d;
	while(x[tmp] == '0') x[tmp--] = '9';
	--x[tmp];
	// debug("%s %s", x + 1, y + 1);
	print((calc(y) - calc(x) + P) % P);
	return 0;
}


//gzhffIThh
#include<bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout);

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;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	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 = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	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);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 1010, D = 55, P = 1000000007;
int n, d;
char s[N], x[N], y[N];
ll p[N][2], f[D][N * D][2];
struct ACAM {
	int rt, si, fail[N * D], to[N * D][11], ed[N * D];
	inline void build() {
		si = rt = 1;
		int len = d / 2;
		for (int i = 1; i + len - 1 <= n; i++){
			int p = rt;
			for (int j = i; j <= len + i - 1; j++) {
				int c = s[j] - '0';
				if(!to[p][c]) to[p][c] = ++si;
				p = to[p][c];
			}
			ed[p] = 1;
		}
	}
	inline void gefi() {
		queue<int> q;
		for (int i = 0; i < 10; i++) to[0][i] = rt;
		q.push(rt);
		while(!q.empty()) {
			int u = q.front(); q.pop();
			for (int i = 0; i < 10; i++) {
				if(to[u][i]) {
					fail[to[u][i]]=to[fail[u]][i];
					q.push(to[u][i]);
				}else {
					to[u][i] = to[fail[u]][i];
				}
			}
		}
	}
}acam;
ll calc(char *str) {
	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] = p[i + 1][0] * (str[i] - '0') + p[i + 1][1];
	}
	ll ans = 0;
	for (int i = 0; i <= d; i++) {
		for (int j = 0; j <= acam.si; 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 <= acam.si; j++) {
			if(!acam.ed[j]) {
				for (int k = 0; k < 10; k++) {
					int o = acam.to[j][k];
					f[i + 1][o][0] = (f[i][j][0] + f[i + 1][o][0]) % P;
					if(k < str[i + 1] - '0') f[i + 1][o][0] = (f[i + 1][o][0] + f[i][j][1]) % P;
					if(k == str[i + 1] - '0') f[i + 1][o][1] = (f[i + 1][o][1] + f[i][j][1]) % P;
				}
			}
		}
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 1; j <= acam.si; j++) {
			if(acam.ed[j]) {
				ans = (ans + (f[i][j][0] * p[i + 1][0]) % P + (f[i][j][1] * p[i + 1][1]) % P) % P;
			}
		}
	}
	return ans % P;
}

int main() {
// 	fl("E");
	rds(s, n); rds(x, d); rds(y, d);
	acam.build(); acam.gefi();
	int tmp = d;
	while(x[tmp] == '0') x[tmp--] = '9';
	--x[tmp];
	// debug("%s %s", x + 1, y + 1);
	print((calc(y) - calc(x) + P) % P);
	return 0;
}


#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int maxnode=1010*25;
const int sigma=10;

struct AC
{
    int val[maxnode],sz,ch[maxnode][sigma],f[maxnode];
    AC()
    {
        sz=1;
        memset(ch[0],0,sizeof(ch[0]));
    }
    void insert(char *s,int n)
    {
        int u=0;
        for(int i=0;i<n;i++)
        {
            int c=s[i]-'0';
            if(!ch[u][c])
            {
                memset(ch[sz],0,sizeof(ch[sz]));
                val[sz]=0;
                ch[u][c]=sz++;
            }
            u=ch[u][c];
        }
        val[u]=1;
    }
    void getFail()
    {
        queue<int> que;
        f[0]=0;
        for(int c=0;c<sigma;c++)
        {
            int u=ch[0][c];
            if(u)
            {
                f[u]=0;
                que.push(u);
            }
        }
        while(!que.empty())
        {
            int r=que.front();que.pop();
            for(int c=0;c<sigma;c++)
            {
                int u=ch[r][c];
                if(!u)
                {
                    ch[r][c]=ch[f[r]][c];
                    continue;
                }
                que.push(u);
                int v=f[r];
                while(v&&!ch[v][c])    v=f[v];
                f[u]=ch[v][c];
                val[u]|=val[f[u]];
            }
        }
    }
}ac;
char str[maxnode],x[maxnode],y[maxnode];
const int mod=1e9+7;
int n,d;
int dp[55][maxnode][2];
int dfs(int pos,int v,int f,int h,char *dig)
{
    if(pos==d)    return h;
    if(!f&&dp[pos][v][h]!=-1)    return dp[pos][v][h];
    int m=f?(dig[pos]-'0'):9;
    int ans=0;
    for(int i=0;i<=m;i++)
        ans=(ans+dfs(pos+1,ac.ch[v][i],f&&i==m,h||ac.val[ac.ch[v][i]],dig))%mod;
    if(!f)    dp[pos][v][h]=ans;
    return ans;
}
int main()
{
    scanf("%s%s%s",str,x,y);
    n=strlen(str),d=strlen(x);
    for(int i=0;i+d/2<=n;i++)
        ac.insert(str+i,d/2);
    ac.getFail();
    memset(dp,-1,sizeof(dp));
    int ans1=dfs(0,0,1,0,x);
    memset(dp,-1,sizeof(dp));
    int ans2=dfs(0,0,1,0,y);
    int u=0,ans3=0;
    for(int i=0;i<d;i++)
    {
        u=ac.ch[u][x[i]-'0'];
        if(ac.val[u])    ans3=1;
    }
    printf("%d\n",((ans2-ans1+ans3)%mod+mod)%mod);
    return 0;
}


#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int maxnode=1010*25;
const int sigma=10;

struct AC
{
    int val[maxnode],sz,ch[maxnode][sigma],f[maxnode];
    AC()
    {
        sz=1;
        memset(ch[0],0,sizeof(ch[0]));
    }
    void insert(char *s,int n)
    {
        int u=0;
        for(int i=0;i<n;i++)
        {
            int c=s[i]-'0';
            if(!ch[u][c])
            {
                memset(ch[sz],0,sizeof(ch[sz]));
                val[sz]=0;
                ch[u][c]=sz++;
            }
            u=ch[u][c];
        }
        val[u]=1;
    }
    void getFail()
    {
        queue<int> que;
        f[0]=0;
        for(int c=0;c<sigma;c++)
        {
            int u=ch[0][c];
            if(u)
            {
                f[u]=0;
                que.push(u);
            }
        }
        while(!que.empty())
        {
            int r=que.front();que.pop();
            for(int c=0;c<sigma;c++)
            {
                int u=ch[r][c];
                if(!u)
                {
                    ch[r][c]=ch[f[r]][c];
                    continue;
                }
                que.push(u);
                int v=f[r];
                while(v&&!ch[v][c])    v=f[v];
                f[u]=ch[v][c];
                val[u]|=val[f[u]];
            }
        }
    }
}ac;
char str[maxnode],x[maxnode],y[maxnode];
const int mod=1e9+7;
int n,d;
int dp[55][maxnode];
int dfs(int pos,int v,int f,int h,char *dig)
{
    if(pos==d)    return h;
    if(!f&&dp[pos][v]!=-1)    return dp[pos][v];
    int m=f?(dig[pos]-'0'):9;
    int ans=0;
    for(int i=0;i<=m;i++)
        ans=(ans+dfs(pos+1,ac.ch[v][i],f&&i==m,h||ac.val[ac.ch[v][i]],dig))%mod;
    if(!f)    dp[pos][v]=ans;
    return ans;
}
int main()
{
    scanf("%s%s%s",str,x,y);
    n=strlen(str),d=strlen(x);
    for(int i=0;i+d/2<=n;i++)
        ac.insert(str+i,d/2);
    ac.getFail();
    memset(dp,-1,sizeof(dp));
    int ans1=dfs(0,0,1,0,x);
    memset(dp,-1,sizeof(dp));
    int ans2=dfs(0,0,1,0,y);
    int u=0,ans3=0;
    for(int i=0;i<d;i++)
    {
        u=ac.ch[u][x[i]-'0'];
        if(ac.val[u])    ans3=1;
    }
    printf("%d\n",((ans2-ans1+ans3)%mod+mod)%mod);
    return 0;
}


#if 0
date

(cf585f)
solution
#endif
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;
struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	inline operator char () { char x[3]; return scanf("%s", x), *x; }
} read;

const int maxn = 1005, maxd = 55, mod = 1000000007;
char s[maxn], t[maxd];
int ch[maxn * maxd][10], fail[maxn * maxd], cp = 1;
bool word[maxn * maxd];
ll f[maxd][maxn * maxd][2][2];

void trans(int i, int j, int p, int q) {
	int X = t[i + 1] - '0';
	for(int x = 0; x < 10; x ++) {
		int k = j;
		while(k and !ch[k][x])
			k = fail[k];
		k = k ? ch[k][x] : 1;
		if(p & (x > X)) break;
		f[i + 1][k][p & (x == X)][q | word[k]] += f[i][j][p][q];
	}
}

void dp(int m) {
	memset(f, 0, sizeof f);
	f[0][1][1][0] = 1;
	for(int i = 0; i < m; i ++)
		for(int j = 1; j <= cp; j ++)
			for(int p = 0; p < 2; p ++)
				for(int q = 0; q < 2; q ++) {
					f[i][j][p][q] %= mod;
					trans(i, j, p, q);
				}
}

int main() {
	scanf("%s", s + 1);
	int n = int(strlen(s + 1));

	scanf("%s", t + 1);
	int m = int(strlen(t + 1));

	for(int p = 1; p + (m >> 1) - 1 <= n; p ++) {
		int now = 1;
		for(int i = p; i < p + (m >> 1); i ++) {
			int &to = ch[now][s[i] - '0'];
			if(!to) to = ++ cp;
			now = to;
		}
		word[now] = 1;
	}

	std::queue<int> q;
	q.push(1);
	while(!q.empty()) {
		int u = q.front();
		q.pop();
		for(int x = 0; x < 10; x ++)
			if(ch[u][x]) {
				int p = fail[u];
				while(p and !ch[p][x])
					p = fail[p];
				fail[ch[u][x]] = p ? ch[p][x] : 1;
			}
	}

	dp(m);
	ll ans = 0;
	for(int j = 1; j <= cp; j ++)
		ans -= f[m][j][0][1];

	scanf("%s", t + 1);
	dp(m);
	for(int j = 1; j <= cp; j ++)
		ans += f[m][j][0][1] + f[m][j][1][1];

	ans %= mod;
	if(ans < 0) ans += mod;
	printf("%lld\n", ans);
}


#if 0
2020.03.04

把 S 所有长为 d / 2 的子串拿出来建 AC 自动机。
然后在 AC 自动机上做数位 DP ：
设 f[i][j][p][q] 表示考虑前 i 位满足如下条件的方案数：
匹配到 AC 自动机的 j 节点，
p 表示前 i 位是否完全等于范围上限，
q 表示是否到达过单词节点。
#endif
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

const int maxn = 1005, maxd = 55, mod = 1000000007;
char s[maxn], t[maxd];
int ch[maxn * maxd][10], fail[maxn * maxd], cp = 1;
bool word[maxn * maxd];
ll f[maxd][maxn * maxd][2][2];

void trans(int i, int j, int p, int q) {
	int X = t[i + 1] - '0';
	for(int x = 0; x < 10; x ++) {
		int k = j;
		while(k and !ch[k][x])
			k = fail[k];
		k = k ? ch[k][x] : 1;
		if(p & (x > X)) break;
		f[i + 1][k][p & (x == X)][q | word[k]] += f[i][j][p][q];
	}
}

void dp(int m) {
	memset(f, 0, sizeof f);
	f[0][1][1][0] = 1;
	for(int i = 0; i < m; i ++)
		for(int j = 1; j <= cp; j ++)
			for(int p = 0; p < 2; p ++)
				for(int q = 0; q < 2; q ++) {
					f[i][j][p][q] %= mod;
					trans(i, j, p, q);
				}
}

int main() {
	scanf("%s", s + 1);
	int n = int(strlen(s + 1));

	scanf("%s", t + 1);
	int m = int(strlen(t + 1));

	for(int p = 1; p + (m >> 1) - 1 <= n; p ++) {
		int now = 1;
		for(int i = p; i < p + (m >> 1); i ++) {
			int &to = ch[now][s[i] - '0'];
			if(!to) to = ++ cp;
			now = to;
		}
		word[now] = 1;
	}

	std::queue<int> q;
	q.push(1);
	while(!q.empty()) {
		int u = q.front();
		q.pop();
		for(int x = 0; x < 10; x ++)
			if(ch[u][x]) {
				int p = fail[u];
				while(p and !ch[p][x])
					p = fail[p];
				fail[ch[u][x]] = p ? ch[p][x] : 1;
				q.push(ch[u][x]);
			}
	}

	dp(m);
	ll ans = 0;
	for(int j = 1; j <= cp; j ++)
		ans -= f[m][j][0][1];

	scanf("%s", t + 1);
	dp(m);
	for(int j = 1; j <= cp; j ++)
		ans += f[m][j][0][1] + f[m][j][1][1];

	ans %= mod;
	if(ans < 0) ans += mod;
	printf("%lld\n", ans);
}


#if 0
date

(cf585f)
solution
#endif
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

const int maxn = 1005, maxd = 55, mod = 1000000007;
char s[maxn], t[maxd];
int ch[maxn * maxd][10], fail[maxn * maxd], cp = 1;
bool word[maxn * maxd];
ll f[maxd][maxn * maxd][2][2];

void trans(int i, int j, int p, int q) {
	int X = t[i + 1] - '0';
	for(int x = 0; x < 10; x ++) {
		int k = j;
		while(k and !ch[k][x])
			k = fail[k];
		k = k ? ch[k][x] : 1;
		if(p & (x > X)) break;
		f[i + 1][k][p & (x == X)][q | word[k]] += f[i][j][p][q];
	}
}

void dp(int m) {
	memset(f, 0, sizeof f);
	f[0][1][1][0] = 1;
	for(int i = 0; i < m; i ++)
		for(int j = 1; j <= cp; j ++)
			for(int p = 0; p < 2; p ++)
				for(int q = 0; q < 2; q ++) {
					f[i][j][p][q] %= mod;
					trans(i, j, p, q);
				}
}

int main() {
	scanf("%s", s + 1);
	int n = int(strlen(s + 1));

	scanf("%s", t + 1);
	int m = int(strlen(t + 1));

	for(int p = 1; p + (m >> 1) - 1 <= n; p ++) {
		int now = 1;
		for(int i = p; i < p + (m >> 1); i ++) {
			int &to = ch[now][s[i] - '0'];
			if(!to) to = ++ cp;
			now = to;
		}
		word[now] = 1;
	}

	std::queue<int> q;
	q.push(1);
	while(!q.empty()) {
		int u = q.front();
		q.pop();
		for(int x = 0; x < 10; x ++)
			if(ch[u][x]) {
				int p = fail[u];
				while(p and !ch[p][x])
					p = fail[p];
				fail[ch[u][x]] = p ? ch[p][x] : 1;
				q.push(ch[u][x]);
			}
	}

	dp(m);
	ll ans = 0;
	for(int j = 1; j <= cp; j ++)
		ans -= f[m][j][0][1];

	scanf("%s", t + 1);
	dp(m);
	for(int j = 1; j <= cp; j ++)
		ans += f[m][j][0][1] + f[m][j][1][1];

	ans %= mod;
	if(ans < 0) ans += mod;
	printf("%lld\n", ans);
}


#include<bits/stdc++.h>
const int N=1010;
char s[N];
long long L,R;
int nod=1,a[N],ch[N][10];
bool query(long long x){
	std::vector<int> v;
	while(x)v.push_back(x%10),x/=10;
	std::reverse(v.begin(),v.end());
	int u=1;
	for(int i=0;i<v.size();i++)u=ch[u][v[i]];
	return tag[u];
}
int main(){
	scanf("%s%lld%lld",s+1,&L,&R),len=strlen(s+1);
	for(int i=1;i<=len;i++)a[i]=s[i]-'0';
	for(long long x=L;x;x/=10)++d;
	for(int l=1,r=(d>>1);r<=len;l++,r++){
		int u=1;
		for(int i=l;i<=r;i++){
			if(!ch[u][a[i]])ch[u][a[i]]=++nod;
			u=ch[u][a[i]];
		}
		tag[u]=true;
	}
	for(int i=0;i<10;i++)
	while(q.size()){
		int u=q.front(); q.pop();
		for(int i=0;i<10;i++)if(ch[u][i]){
			q.push(ch[u][i]);
			fail[ch[u][i]]=u==1?1:ch[fail[u]][i];
		}else{
			fail[ch[u][i]]=u==1?1:ch[fail[u]][i];
		}
	}
	for(int u=1;u<=nod;u++)if(tag[u]){
		for(int i=0;i<10;i++)ch[u][i]=u;
	}
	for(long long i=L;i<=R;i++)ans+=query(i);
//	ans=solve(R)-solve(L)+query(L);
	printf("%lld\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int kcz=1000000007;
const int maxn=300005;
const int maxd=55;
struct node
{
    int ne[26],pre,sz;
    inline node() { memset(ne,-1,sizeof(ne)); pre=0; sz=0; }
}ch[maxn];
int tot;
inline void add(char *str)
{
    int i;
    for(i=0;*str;i=ch[i].ne[*str-'0'],str++)
        if(ch[i].ne[*str-'0']==-1)
            ch[i].ne[*str-'0']=++tot;
    ch[i].sz++;
}
inline void ac()
{
    int i,j,k;
    queue<int> que;
    while(!que.empty()) que.pop();
    que.push(0); ch[0].pre=-1;
    while(!que.empty())
    {
        i=que.front(),que.pop();
        for(j=0;j<26;j++)
            if(ch[i].ne[j]!=-1)
            {
                for(k=ch[i].pre;k!=-1;)
                    if(ch[k].ne[j]!=-1)
                        break;
                    else k=ch[k].pre;
                if(k==-1) ch[ch[i].ne[j]].pre=0;
                else ch[ch[i].ne[j]].pre=ch[k].ne[j];
                que.push(ch[i].ne[j]);
            }
    }
}
char temp[maxn],l[maxn],r[maxn];
int n;
ll f[maxd][maxn],g[maxd][maxn];
inline int next_(int cur,char c)
{
    while(cur!=-1 && ch[cur].ne[c-'0']==-1)
        cur=ch[cur].pre;
    if(cur==-1) cur=0;
    else cur=ch[cur].ne[c-'0'];
    return cur;
}
inline int check(char *s)
{
    int i,cur=0;
    for(i=0;s[i];i++)
    {
        cur=next_(cur,s[i]);
        if(ch[cur].sz) return 1;
    }
    return 0;
}
inline ll solve(char *s)
{
    int i,j,k,m,_,cur=0; m=strlen(s);
    ll res=0;
//    for(i=1;i<m;i++)
//        (res+=g[i][0])%=kcz;
    for(_=0;_<m;_++)
    {
#define g f
        memset(g,0,sizeof(g));
        g[0][cur]=1;
        for(i=1;i<=m-_;i++)
            for(j=0;j<=tot;j++)
                for(k=(!_ && i==1)?'1':'0';k<=((i==1)?s[_]-1:'9');k++)
                    if(!ch[j].sz)
                        (g[i][next_(j,k)]+=g[i-1][j])%=kcz;
                    else (g[i][j]+=g[i-1][j])%=kcz;
        for(i=0;i<=tot;i++)
            if(ch[i].sz)
                (res+=g[m-_][i])%=kcz;
#undef g
        if(!ch[cur].sz) cur=next_(cur,s[_]);
    }
    if(ch[cur].sz) (res+=1)%=kcz;
    return res;
}
int main()
{
    int i,j,k;
    scanf("%s%s%s",temp,l,r),n=strlen(l),k=strlen(temp);
    for(tot=0,i=k-n/2;i>=0;i--) temp[i+n/2]='\0',add(temp+i);
    ac();
//    for(i=0;i<tot;i++) g[1][i]=0;
//    memset(g,0,sizeof(g));
//    for(i='1';i<='9';i++) g[1][next_(0,i)]++;
////    n=max(strlen(l),strlen(r));
//    for(i=2;i<=n;i++)
//        for(j=0;j<=tot;j++)
//            if(!ch[j].sz)
//                for(k='0';k<='9';k++)
//                    (g[i][next_(j,k)]+=g[i-1][j])%=kcz;
//            else (g[i][j]+=g[i-1][j])%=kcz;
//    for(i=1;i<=n;i++)
//        for(g[i][0]=0,j=1;j<=tot;j++)
//            if(ch[j].sz)
//                (g[i][0]+=g[i][j])%=kcz;
    printf("%lld\n",(solve(r)-solve(l)+check(l)+kcz)%kcz);
    return 0;
}


// Problem: CF585F Digits of Number Pi
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/CF585F
// Memory Limit: 250 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
//#include <immintrin.h>
//#include <emmintrin.h>

#include <bits/stdc++.h>
//#pragma GCC optimize("O2")
#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define all2(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define mt make_tuple
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define contain(S,X) (((S)&o(X))!=0)
#define containL(S,X) (((S)&oL(X))!=0)
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
inline int getplc(int x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}
// Smax
//int Smax() { return -INF; }
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
// Smin
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
// erro
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }

void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}
void Solve();
int main() {
#ifndef ONLINE_JUDGE
//	freopen("in.txt","r",stdin);
//    freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}

//////////////////////////////////////////////////////////////////

template<const int &MOD>
struct _m_int {
	int val;

	_m_int(int64_t v = 0) {
		if (v < 0) v = v % MOD + MOD;
		if (v >= MOD) v %= MOD;
		val = int(v);
	}

	static int inv_mod(int a, int m = MOD) {
		// https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Example
		int g = m, r = a, x = 0, y = 1;

		while (r != 0) {
			int q = g / r;
			g %= r; swap(g, r);
			x -= q * y; swap(x, y);
		}

		return x < 0 ? x + m : x;
	}

	explicit operator int() const { return val; }
	explicit operator int64_t() const { return val; }

	_m_int& operator+=(const _m_int &other) {
		val -= MOD - other.val;
		if (val < 0) val += MOD;
		return *this;
	}

	_m_int& operator-=(const _m_int &other) {
		val -= other.val;
		if (val < 0) val += MOD;
		return *this;
	}

	static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
#if !defined(_WIN32) || defined(_WIN64)
		return unsigned(x % m);
#endif
		// Optimized mod for Codeforces 32-bit machines.
		// x must be less than 2^32 * m for this to work, so that x / m fits in an unsigned 32-bit int.
		unsigned x_high = unsigned(x >> 32), x_low = unsigned(x);
		unsigned quot, rem;
		asm("divl %4\n"
		: "=a" (quot), "=d" (rem)
		: "d" (x_high), "a" (x_low), "r" (m));
		return rem;
	}

	_m_int& operator*=(const _m_int &other) {
		val = fast_mod(uint64_t(val) * other.val);
		return *this;
	}

	_m_int& operator/=(const _m_int &other) {
		return *this *= other.inv();
	}

	friend _m_int operator+(const _m_int &a, const _m_int &b) { return _m_int(a) += b; }
	friend _m_int operator-(const _m_int &a, const _m_int &b) { return _m_int(a) -= b; }
	friend _m_int operator*(const _m_int &a, const _m_int &b) { return _m_int(a) *= b; }
	friend _m_int operator/(const _m_int &a, const _m_int &b) { return _m_int(a) /= b; }

	_m_int& operator++() {
		val = val == MOD - 1 ? 0 : val + 1;
		return *this;
	}

	_m_int& operator--() {
		val = val == 0 ? MOD - 1 : val - 1;
		return *this;
	}

	_m_int operator++(int) { _m_int before = *this; ++*this; return before; }
	_m_int operator--(int) { _m_int before = *this; --*this; return before; }

	_m_int operator-() const {
		return val == 0 ? 0 : MOD - val;
	}

	bool operator==(const _m_int &other) const { return val == other.val; }
	bool operator!=(const _m_int &other) const { return val != other.val; }

	_m_int inv() const {
		return inv_mod(val);
	}

	_m_int pow(int64_t p) const {
		if (p < 0)
			return inv().pow(-p);

		_m_int a = *this, result = 1;

		while (p > 0) {
			if (p & 1)
				result *= a;

			p >>= 1;

			if (p > 0)
				a *= a;
		}

		return result;
	}

	friend ostream& operator<<(ostream &os, const _m_int &m) {
		return os << m.val;
	}
};

extern const int _MOD = 1e9+7;
using mint = _m_int<_MOD>;

struct state{
  int len,link;
  int next[11];
};
const int MAX_LEN=2*4e3+5;
state st[MAX_LEN];
int sz,last;
void sam_init(){
  st[0].len=0;
  st[0].link=-1;
  sz++;
  last=0;
}
int cnt[MAX_LEN];
void sam_extend(char c){
  int cur=sz++;
  cnt[cur]++;
  st[cur].len=st[last].len+1;
  int p=last;
  while(p!=-1&&!st[p].next[c]){
    st[p].next[c]=cur;
    p=st[p].link;
  }
  if(p==-1) st[cur].link=0;
  else{
    int q=st[p].next[c];
    if(st[p].len+1==st[q].len) st[cur].link=q;
    else{
      int clone=sz++;
      st[clone]=st[q];
      st[clone].len=st[p].len+1;
      while(p!=-1&&st[p].next[c]==q){
        st[p].next[c]=clone;
        p=st[p].link;
      }
      st[q].link=st[cur].link=clone;
    }
  }
  last=cur;
}

int n,d;
char s[N],a[N],b[N];

mint f[55][3005][55][2][2];
mint solve(char *s,int x,int cur,int len,int lim,int flag){
    // error(flag)
  if(x>d){
    return mint(flag);
  }
  if(f[x][cur][len][lim][flag]!=-1)return f[x][cur][len][lim][flag];
  int ccur=cur,up=lim?s[x]-'0':9;
  mint ans;
  rep(i,0,up){
    if(flag)ans+=solve(s,x+1,cur,len,lim&(i==up),flag);
    else{
      int p=cur;
      if(st[p].next[i])
        ans+=solve(s,x+1,st[p].next[i],len+1,lim&(i==up),
          flag|(len+1>=d/2));
      else{
        while(p&&!st[p].next[i])p=st[p].link;
        if(p)
          ans+=solve(s,x+1,st[p].next[i],st[p].len+1,lim&(i==up),
            st[p].len+1>=d/2);
        else
          ans+=solve(s,x+1,0,0,lim&(i==up),0>=d/2);
      }
    }
  }
  f[x][cur][len][lim][flag]=ans;
  return ans;
}

mint work(char *s){
  rep(i1,0,51)
  rep(i2,0,3002)
  rep(i3,0,51)
  rep(i4,0,1)
  rep(i5,0,1)
  f[i1][i2][i3][i4][i5]=-1;
  return solve(s,1,0,0,1,0);
}

void Solve(){
  cin>>s+1>>a+1>>b+1;
  n=strlen(s+1),d=strlen(a+1);
  a[d]--;
  per(i,1,d)if(a[i]=='0'+-1)a[i-1]--,a[i]='9';else break;
  // rep(i,1,d)error(i,b[i]-'0');
  sam_init();
  rep(i,1,n)sam_extend(s[i]-'0');
  mint ans=work(b)-work(a);
  cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5,mod=1e9+7;
inline void add(int &x,int y){
	x+=y;if(x>=mod) x-=mod;
}
int n,m,d;
char s[N],a[N],b[N];
int c[N][10],fail[N],ed[N],tot=0;
int f[55][N][2],p[N][2],x[N];
inline void ins(int l,int r){
	int now=0;
	for(int i=l;i<=r;i++) {
		int u=s[i]-'0';
		if(!c[now][u]) c[now][u]=++tot;
		now=c[now][u];
	}
	ed[now]=1;
}
inline void build(){
	queue<int> q;
	for(int i=0;i<10;i++) if(c[0][i]) q.push(c[0][i]);
	while(!q.empty()){
		int u=q.front();q.pop();
		for(int i=0;i<10;i++)
			if(c[u][i]) fail[c[u][i]]=c[fail[u]][i],q.push(c[u][i]);
			else c[u][i]=c[fail[u]][i];
	}
}
int dfs(int i,int u,int lim){
	if(ed[u]) return p[i][lim];
	if(i>d) return 0;
	if(f[i][u][lim]!=-1) return f[i][u][lim];
	int ans=0;
	for(int j=0;j<=(lim?x[i]:9);j++) add(ans,dfs(i+1,c[u][j],(j==x[i])&lim));
	return f[i][u][lim]=ans;
}
inline int calc(char *s){
	for(int i=1;i<=d;i++) x[i]=s[i]-'0';
	p[d+1][0]=p[d+1][1]=1;
	for(int i=d;i>=1;i--) p[i][0]=p[i+1][0]*10ll%mod,p[i][1]=(1ll*x[i]*p[i+1][0]+p[i+1][1])%mod;
	memset(f,-1,sizeof(f));
	return dfs(1,0,1);
}
int main(){
	scanf("%s%s%s",s+1,a+1,b+1);
	n=strlen(s+1),d=strlen(a+1),m=d>>1;
	for(int i=1;i+m-1<=n;i++) ins(i,i+m-1);build();
	for(int i=d;a[i]=='0'?1:(0&(--a[i]));i--) a[i]='9';
	printf("%d",(calc(b)-calc(a)+mod)%mod);
	return 0;
}