#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
const int mod = 1e9 + 7;
const int N = 100;

int a[N];
int n, m, k;
int ans ;
long long dp[N][N];
bool check (long long s) {
while (s) {
if (s % 10 == 7) return 1;
if (s % 10 == 9) return 1;
s /= 10;
}
return 0;
}
void solve() {
cin >> n >> m >> k;

for (int i = 1; i <= m; i ++) cin >> a[i];
dp[0][0] = 1;
for (int i = 0; i < n; i ++) {
for (int j = 0; j < k; j ++) {
for (int l = 1; l <= m; l ++)
dp[i + 1][(j + a[l]) % k]= (dp[i + 1][(j + a[l]) % k] + dp[i][j]) % mod;
}
}
long long ans = 0;
for (int i = 0; i < k; i ++) {
if (check(i))
(ans += dp[n][i]) %= mod;
}
cout << ans << endl;
}
int main () {
int t;
t =1 ;
while (t--) solve();
return 0;
}
dp[i][j]表示前i个回合中在余数位j的方案数
题目要求什么就定义什么
向前转移
注意数据范围
回合数为阶段,余数的角度想