#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T x, T y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    T f = x % y;
    x = y;
    y = f;
  }
  return x;
}
const int maxN = 1000100;
const int maxM = 100;
int N, L, M;
int A[maxN], AM[maxM];
int B[maxN], BM[maxM];
int C[maxN], CM[maxM];
typedef long long Mat[maxM][maxM];
const long long MM = 1e9 + 7;
void matmul(Mat R, Mat A, Mat B) {
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      R[i][j] = 0;
      for (int k = 0; k < M; k++) R[i][j] = (R[i][j] + A[i][k] * B[k][j]) % MM;
    }
  }
}
void matpow(Mat R, Mat A, int n) {
  Mat x, tmp;
  memcpy(x, A, sizeof(x));
  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++) R[i][j] = i == j ? 1 : 0;
  while (n) {
    if (n & 1) {
      memcpy(tmp, R, sizeof(tmp));
      matmul(R, tmp, x);
    }
    memcpy(tmp, x, sizeof(x));
    matmul(x, tmp, tmp);
    n /= 2;
  }
}
int main(int argc, char *argv[]) {
  std::cin.sync_with_stdio(false);
  std::cin.tie(nullptr);
  cin >> N >> L >> M;
  {
    memset(AM, 0, sizeof(AM));
    memset(BM, 0, sizeof(BM));
    memset(CM, 0, sizeof(CM));
    for (int i = 0; i < N; i++) cin >> A[i], AM[A[i] % M]++;
    for (int i = 0; i < N; i++) cin >> B[i], BM[B[i] % M]++;
    for (int i = 0; i < N; i++)
      cin >> C[i], C[i] += B[i], CM[(M * M - C[i]) % M]++;
    Mat BB, BBP;
    memset(BB, 0, sizeof(BB));
    for (int i = 0; i < M; i++)
      for (int j = 0; j < M; j++) BB[i][(i + j) % M] += BM[j];
    matpow(BBP, BB, L - 2);
    long long res = 0;
    for (int i = 0; i < M; i++)
      for (int j = 0; j < M; j++) {
        res = (res + (((BBP[i][j] * AM[i]) % MM) * CM[j])) % MM;
      }
    cout << res << endl;
  }
  return 0;
}
