#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7, mxn = 1e5 + 5, mxm = 105;
inline void add(int& x, int y) {
  x += y;
  if (x >= md) x -= md;
}
struct mat {
  int a[mxm][mxm];
  inline mat operator*(const mat& b) const {
    mat c;
    memset(c.a, 0, sizeof(c.a));
    for (int i = 0; i < mxm; ++i)
      for (int j = 0; j < mxm; ++j)
        for (int k = 0; k < mxm; ++k)
          add(c.a[i][j], 1ll * a[i][k] * b.a[k][j] % md);
    return c;
  }
} ans, t;
int b[mxn * 10], sol, n, m, l;
int main() {
  scanf("%d%d%d", &n, &l, &m);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x), ++ans.a[0][x % m];
  }
  for (int i = 0; i < n; ++i) scanf("%d", b + i), b[i] %= m;
  for (int j = 0; j < m; ++j)
    for (int i = 0; i < n; ++i) ++t.a[(m + j - b[i]) % m][j];
  for (l -= 2; l; t = t * t, l >>= 1)
    if (l & 1) ans = ans * t;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x), x %= m, add(sol, ans.a[0][(2 * m - x - b[i]) % m]);
  }
  printf("%d\n", sol);
}
