#include <bits/stdc++.h>
using namespace std;
long long n, m, md, i, j, to[1234567], co[1234567], fr[1234567];
struct cc {
  long long arr[123][123];
} a, b;
cc mul(cc a, cc b) {
  int i, j, k;
  cc ans;
  memset(ans.arr, 0, sizeof(ans.arr));
  for (i = 0; i < md; i++) {
    for (j = 0; j < md; j++) {
      for (k = 0; k < md; k++) {
        ans.arr[i][k] += a.arr[i][j] * b.arr[j][k];
        ans.arr[i][k] %= 1000000007;
      }
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  ;
  cin >> n >> m >> md;
  m--;
  m--;
  for (i = 1; i <= n; i++) {
    cin >> fr[i];
  }
  for (i = 1; i <= n; i++) {
    cin >> co[i];
  }
  for (i = 1; i <= n; i++) {
    cin >> to[i];
  }
  memset(a.arr, 0, sizeof(a.arr));
  memset(b.arr, 0, sizeof(b.arr));
  for (i = 0; i < md; i++) {
    for (j = 1; j <= n; j++) {
      a.arr[(i - co[j] + md) % md][i]++;
    }
  }
  for (i = 1; i <= n; i++) b.arr[0][fr[i] % md]++;
  while (m) {
    if (m & 1) b = mul(b, a);
    a = mul(a, a);
    m /= 2;
  }
  long long ans = 0;
  for (i = 1; i <= n; i++) {
    ans += b.arr[0][((-co[i] - to[i]) % md + md) % md];
    ans %= 1000000007;
  }
  cout << ans;
  return 0;
}
