#include <bits/stdc++.h>
using namespace std;
int const M = 1e9 + 7, N = 101, N1 = 1e6 + 5;
int mat[N][N], n, l, m;
void mult(int a[N][N], int b[N][N]) {
  int cp[N][N] = {};
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k < m; k++) {
        cp[i][j] += 1LL * a[i][k] * b[k][j] % M;
        if (cp[i][j] >= M) cp[i][j] -= M;
      }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) a[i][j] = cp[i][j];
}
int x[N], y[N], z[N1];
void power(int e) {
  int ans[N][N] = {};
  for (int i = 0; i < 101; i++) ans[i][i] = 1;
  while (e) {
    if (e & 1) mult(ans, mat);
    mult(mat, mat);
    e >>= 1;
  }
  int ans1 = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k < m; k++) {
        if ((k + i + j) % m) continue;
        ans1 += ((1LL * ans[0][k] * x[i] % M) * y[j]) % M;
        if (ans1 >= M) ans1 -= M;
      }
  cout << ans1 << endl;
}
int main() {
  scanf("%d%d%d", &n, &l, &m);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    x[a % m]++;
  }
  unordered_map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    z[i] = a % m;
    mp[a % m]++;
    for (int j = 0; j < m; j++) mat[j][(j + a) % m]++;
  }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) mat[i][j] = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) mat[i][j] = mp[(j - i + m) % m];
  }
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    y[(a + z[i]) % m]++;
  }
  power(l - min(l, 2));
}
