#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int mod = 1e9+7;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
int binpow(int a, int b)
{
int res = 1;
a = a % mod;
while (b != 0)
{
if (b & 1)
{
res = (res * a) % mod;
}
a = (a * a) % mod;
b = b >> 1;
}
return res;
}
int n,m,k;
vector<int> a;
vector<vector<int>> g;
vector<vector<int>> gg;
int dp[10001][101][10];
int rec(int level,int mat,int k){
if(level==n){
return 1;
}
// cout<<level<<endl;
if(dp[level][mat][k]!=-1){
return dp[level][mat][k];
}
int ans = 0;
for(auto v : gg[k]){
int mm = g[mat][v];
if(mm!=m){
ans = (ans + rec(level+1,mm,v))%mod;
}
}
dp[level][mat][k] = ans;
return ans;
}
void solve()
{
cin>>n>>m>>k;
string s;
cin>>s;
memset(dp,-1,sizeof(dp));
if(m==0){cout<<0<<endl; return;}
gg.resize(10);
gg[0] = {4,6};
gg[1] = {6,8};
gg[2] = {7,9};
gg[3] = {8,4};
gg[4] = {3,9,0};
gg[6] = {1,7,0};
gg[7] = {2,6};
gg[8] = {1,3};
gg[9] = {4,2};
g.assign(m + 1, vector<int>(10, 0));
for (int i = 0; i <= m; i++){
for (int j = 0; j < 10; j++){
string t = "";
for (int k = 0; k < i; k++) t += s[k];
t += (char)('0' + j);
for (int len = 1; len <= (int)t.size(); len++){
bool good = true;
int start = (int)t.size() - len;
for (int k = 0; k < len; k++) if (t[start + k] != s[k]) good = false;
if (good) g[i][j] = len;
}
// cout<<i<<" "<<j<<" "<<g[i][j]<<endl;
}
}
//cout<<g[0][3]<<endl;
cout<<rec(0,0,k)<<endl;
return;
}
signed main()
{
ios::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
int t = 1;
// cin >> t;
while (t-- != 0)
{
// cout<<t<<endl;
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgaW50IGxvbmcgbG9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ZihtPT0wKXtjb3V0PDwwPDxlbmRsOyByZXR1cm47fQogIGdnLnJlc2l6ZSgxMCk7CgogIGdnWzBdID0gezQsNn07CiAgZ2dbMV0gPSB7Niw4fTsKICBnZ1syXSA9IHs3LDl9OwogIGdnWzNdID0gezgsNH07CiAgZ2dbNF0gPSB7Myw5LDB9OwogIGdnWzZdID0gezEsNywwfTsKICBnZ1s3XSA9IHsyLDZ9OwogIGdnWzhdID0gezEsM307CiAgZ2dbOV0gPSB7NCwyfTsKCiAgICBnLmFzc2lnbihtICsgMSwgdmVjdG9yPGludD4oMTAsIDApKTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDw9IG07IGkrKyl7CiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCAxMDsgaisrKXsKICAgICAgICAgICAgc3RyaW5nIHQgPSAiIjsKICAgICAgICAgICAgZm9yIChpbnQgayA9IDA7IGsgPCBpOyBrKyspIHQgKz0gc1trXTsKICAgICAgICAgICAgdCArPSAoY2hhcikoJzAnICsgaik7CiAgICAgICAgICAgIAogICAgICAgICAgICBmb3IgKGludCBsZW4gPSAxOyBsZW4gPD0gKGludCl0LnNpemUoKTsgbGVuKyspewogICAgICAgICAgICAgICAgYm9vbCBnb29kID0gdHJ1ZTsKICAgICAgICAgICAgICAgIGludCBzdGFydCA9IChpbnQpdC5zaXplKCkgLSBsZW47CiAgICAgICAgICAgICAgICBmb3IgKGludCBrID0gMDsgayA8IGxlbjsgaysrKSBpZiAodFtzdGFydCArIGtdICE9IHNba10pIGdvb2QgPSBmYWxzZTsKICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgaWYgKGdvb2QpIGdbaV1bal0gPSBsZW47CiAgICAgICAgICAgIH0KICAgICAgICAgIC8vICBjb3V0PDxpPDwiICI8PGo8PCIgIjw8Z1tpXVtqXTw8ZW5kbDsKICAgICAgICB9CiAgICB9IAoKICAvL2NvdXQ8PGdbMF1bM108PGVuZGw7CiAgY291dDw8cmVjKDAsMCxrKTw8ZW5kbDsKICByZXR1cm47Cn0KCnNpZ25lZCBtYWluKCkKewogIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICBjb3V0LnRpZSgwKTsKICBjaW4udGllKDApOwogIGludCB0ID0gMTsKICAvLyBjaW4gPj4gdDsKICB3aGlsZSAodC0tICE9IDApCiAgewogICAgLy8gICBjb3V0PDx0PDxlbmRsOwogICAgc29sdmUoKTsKICB9CiAgcmV0dXJuIDA7Cn0=