func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   int n, l, m;   const int MAXN = 1e6 + 5;   long long cini[MAXN], cfin[MAXN];   vector<vector<long long>> owo;   vector<vector<long long>> mul(vector<vector<long long>> A,                                 vector<vector<long long>> B) {     int n = A.size();     vector<vector<long long>> res(n, vector<long long>(n));     for (int k = 0; k < n; k++)       for (int i = 0; i < n; i++)         for (int j = 0; j < n; j++)           res[i][j] = (res[i][j] + A[i][k] * B[k][j]) % MOD;     return res;   }   vector<vector<long long>> mexp(vector<vector<long long>> M, long long e) {     int n = M.size();     vector<vector<long long>> res(n, vector<long long>(n));     for (int i = 0; i < n; i++) res[i][i] = 1;     for (long long k = 1; k <= e; k *= 2) {       if (k & e) res = mul(res, M);       M = mul(M, M);     }     return res;   }   int cost[MAXN];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n >> l >> m;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       cini[x % m]++;     }     owo.assign(m, vector<long long>(m));     for (int i = 0; i < n; i++) {       int x;       cin >> x;       cost[i] = x;       for (int i = 0; i < m; i++) {         owo[i][(x + i) % m]++;       }     }     for (int i = 0; i < n; i++) {       int x;       cin >> x;       cfin[(x + cost[i]) % m]++;     }     vector<vector<long long>> res = mexp(owo, l - 2);     long long ans = 0;     for (int a = 0; a < m; a++) {       for (int b = 0; b < m; b++) {         int rem = (a + b) % m;         if (rem > 0) rem = m - rem;         long long te = ((long long)cini[a] * cfin[b]) % MOD;         ans = (ans + te * res[0][rem]) % MOD;       }     }     cout << ans << endl;   }   