#include #include #include #include #define MOD 1000000007 int next[5010][10]; int prev[5010],fail[5010]; int possible[5010]; int C = 2; void make(long long int k) { int start = 1; std::vector V; while(k) { V.push_back(k%10); k/=10; } std::reverse(V.begin(),V.end()); int control = 0; for(int i=0;i Q; Q.push(1); while(!Q.empty()) { int k = Q.front(); Q.pop(); if(k>1) { if(prev[k]==1) fail[k] = 1; else { int c; for(int i=0;i<=9;i++) { if(next[prev[k]][i]==k) { c = i; break; } } int p = fail[prev[k]]; while(p>=1) { if(next[p][c]!=0) { fail[k] = next[p][c]; goto u; } else p = fail[p]; } fail[k] = 0; u:; } } for(int i=0;i<=9;i++) if(next[k][i]!=0) Q.push(next[k][i]); } } int a; long long int check[5010][5010]; long long int func(int k, int state) { //printf("%d %d : %d!!\n",k,state,possible[state]); if(possible[state]==1) return 0; else if(k>a) return 1; else if(check[k][state]>0) return check[k][state]; else { long long int ans = 1; for(int i=0;i<=9;i++) { int p = state; while(p>=1) { if(next[p][i]!=0) { ans += func(k+1,next[p][i]); goto u; } else p = fail[p]; } ans += func(k+1,1); u:; } return check[k][state] = ans%MOD; } } int main() { scanf("%d",&a); long long int b,c; scanf("%lld%lld",&b,&c); long long int F1 = 1, F2 = 1; if(1>=b) make(F2); while(F2