#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

typedef vector<Vll> Matrix;
Matrix operator *(const Matrix& A, const Matrix& B)
{
	int n = A.size(), m = A[0].size();
	int N = B.size(), M = B[0].size();
	Matrix C= Matrix(n, Vll(M));
	if (m != N)return C;
	fup(i, 0, n - 1, 1)
	{
		fup(j, 0, M - 1, 1)
		{
			fup(k, 0, m - 1, 1)
			{
				C[i][j] += A[i][k] * B[k][j];
				C[i][j]%=MOD;
			}
		}
	}
	return C;
}
int a[101],b[101],c[101];
Matrix mul(Matrix &A,int l)
{
	if(l==1)return A;
	if(l&1)
	{
		return mul(A,l-1)*A;
	}
	else
	{
		Matrix t=mul(A,l/2);
		return t*t;
	}
}
int main() {
	int n,l,m;
	scanf("%d%d%d",&n,&l,&m);
	fup(i,0,n-1,1)
	{
		int x;
		scanf("%d",&x);
		if(x==m)x=0;
		a[x]++;
	}
	fup(i,0,n-1,1)
	{
		int x;
		scanf("%d",&x);
		if(x==m)x=0;
		b[x]++;
	}
	fup(i,0,n-1,1)
	{
		int x;
		scanf("%d",&x);
		if(x==m)x=0;
		c[x]++;
	}
	Matrix B(m,Vll(m));
	fup(i,0,m-1,1)
		fup(j,0,m-1,1)
	{
		B[i][(i+j)%m]=b[j];
	}
	B=mul(B,l-1);
	ll ans=0;
	fup(i,0,m-1,1)
		fup(j,0,m-1,1)
	{
		ll t=(a[i]*B[i][j==0?0:m-j])%MOD;
		t=(t*c[j])%MOD;
		ans=(ans+t)%MOD;
	}
	printf("%lld",(ans+MOD-1)%MOD);
}


#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

typedef vector<Vll> Matrix;
Matrix operator *(const Matrix& A, const Matrix& B)
{
	int n = A.size(), m = A[0].size();
	int N = B.size(), M = B[0].size();
	Matrix C= Matrix(n, Vll(M));
	if (m != N)return C;
	fup(i, 0, n - 1, 1)
	{
		fup(j, 0, M - 1, 1)
		{
			fup(k, 0, m - 1, 1)
			{
				C[i][j] += A[i][k] * B[k][j];
				C[i][j]%=MOD;
			}
		}
	}
	return C;
}
int a[101],b[101],c[101],aa[1000000],bb[1000000],cc[1000000];
Matrix mul(Matrix &A,int l)
{
	if(l==1)return A;
	if(l&1)
	{
		return mul(A,l-1)*A;
	}
	else
	{
		Matrix t=mul(A,l/2);
		return t*t;
	}
}
int main() {
	int n,l,m;
	scanf("%d%d%d",&n,&l,&m);
	fup(i,0,n-1,1)
	{
		scanf("%d",aa+i);
		a[aa[i]%m]++;
	}
	fup(i,0,n-1,1)
	{
		scanf("%d",bb+i);
		b[bb[i]%m]++;
	}
	fup(i,0,n-1,1)
	{
		int x;
		scanf("%d",&x);
		cc[i]=x+bb[i];
		c[cc[i]%m]++;
	}
	if(l==2)
	{
		ll ans=0;
		fup(i,0,m-1,1)
			ans=(ans+a[i]*c[i==0?0:m-i])%MOD;
		return !printf("%lld",ans);
	}
	Matrix B(m,Vll(m));
	fup(i,0,m-1,1)
		fup(j,0,m-1,1)
	{
		B[i][(i+j)%m]=b[j];
	}
	B=mul(B,l-2);
	ll ans=0;
	fup(i,0,m-1,1)
		fup(j,0,m-1,1)
	{
		ll t=(a[i]*B[i][j==0?0:m-j])%MOD;
		t=(t*c[j])%MOD;
		ans=(ans+t)%MOD;
	}
	printf("%lld",ans);
}


#include<stdio.h>
#include<algorithm>
#include<iostream>
#define M 1000000007
#define ll long long
#include<cstring>
#define go(i,a,b) for(int i=a;i<=b;i++)
#define ro(i,a,b) for(int i=a;i>=b;i--)
#define fo(i,a,x) for(int i=a[x],v=e[i].v;i;i=e[i].next,v=e[i].v)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const int N=100003;
const int _2=500000004;
struct E{int v,next;}e[N*2];
int n,head[N],k=1;
bool Leaf(int u){return e[head[u]].next==0;}
ll f[N],ans;
void ADD(int u,int v){e[k]=(E){v,head[u]};head[u]=k++;}
void Dfs(int u,int fa)
{
	f[u]=1;
	if(Leaf(u)&&u!=1)return;
	fo(i,head,u)if(v!=fa)
	{
		Dfs(v,u);
		(f[u]*=f[v])%=M;
	}
	(f[u]<<=1)%=M;
}
void dfs(int u,int fa,ll val)
{
	ll now=val*(Leaf(fa)?_2:1)*(Leaf(u)?2:1);
	(ans+=now)%=M;
	fo(i,head,u)if(v!=fa)dfs(v,u,now);
}
int main()
{

	scanf("%d",&n);
	go(i,2,n)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		ADD(u,v);ADD(v,u);
	}
	Dfs(1,1);ans=f[1];
	fo(i,head,1)if(v!=1)dfs(v,1,f[1]);
	printf("%d\n",(ans%M+M)%M);
	return 0;
}//Paul_Guderian


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define maxn 1000005
#define maxm 105
using namespace std;
int n,m,MOD;
int s[maxn],e[maxn],cnt[maxm],cnts[maxm],cnte[maxm];
char gc(){
	static char s[1000000],*p1=s,*p2=s;
	if(p1==p2) p2=(p1=s)+fread(s,1,1000000,stdin);
	return *p1++;
}
int read(){
	int x=0;char c=gc();
	while(c<'0'||c>'9') c=gc();
	while(c<='9'&&c>='0') x=10*x+c-'0',c=gc();
	return x;
}
struct node{
	long long a[maxm][maxm];
	node operator * (const node &y) const{
		node z;
		for(int i=0;i<MOD;i++)
			for(int j=0;j<MOD;j++){
				z.a[i][j]=0;
				for(int k=0;k<MOD;k++)
					z.a[i][j]=(z.a[i][j]+a[i][k]*y.a[k][j])%1000000007;
			}
		return z;
	}
};
void mo(int &x){if(x>=MOD)x-=MOD;}
node Pow(node x,int y)
{
	node ans;
	for(int i=0;i<MOD;i++)
		for(int j=0;j<MOD;j++)
			if(i==j) ans.a[i][j]=1;
			else ans.a[i][j]=0;
	while(y)
	{
		if(y&1) ans=ans*x;
		x=x*x;
		y>>=1;
	}
	return ans;
}
int main()
{
	n=read(),m=read(),MOD=read();
	for(int i=1;i<=n;i++){
		s[i]=read(),mo(s[i]);
		cnts[s[i]]++;
	}
	for(int i=1;i<=n;i++){
		e[i]=read(),mo(e[i]);
		cnt[e[i]]++;
	}
	for(int i=1;i<=n;i++){
		e[i]+=read(),mo(e[i]);
		cnte[e[i]]++;
	}
	node M,S,E;
	//memset(S.a,0,sizeof(S.a));
	for(int i=0;i<MOD;i++){
		for(int j=0;j<MOD;j++){
			int k=i+j;
			mo(k);
			M.a[i][k]=cnt[j];
			S.a[i][k]=cnts[j];
			E.a[i][k]=cnte[j];
		}
	}
	node Zero;
	memset(Zero.a,0,sizeof(Zero.a));
	Zero.a[0][0]=1;
	node x;
	if(m>2)
		x=Zero*S*Pow(M,m-2)*E;
	else
		x=Zero*S*E;
	cout<<x.a[0][0];
	return 0;
}


#include <bits/stdc++.h>
#define For(i,a,b) for ( int i=(a);i<=(b);i++ )
#define Dow(i,b,a) for ( int i=(b);i>=(a);i-- )
#define GO(i,x) for ( int i=head[x];i;i=e[i].nex )
#define mem(x,s) memset(x,s,sizeof(x))
#define cpy(x,s) memcpy(x,s,sizeof(x))
#define YES return puts("YES"),0
#define NO return puts("NO"),0
#define GG return puts("-1"),0
#define pb push_back
#define int long long
using namespace std;

struct IO
{
	#define MAXSIZE (1 << 20)
	#define isdigit(x) (x >= '0' && x <= '9')
  	char buf[MAXSIZE],*p1,*p2;
  	char pbuf[MAXSIZE],*pp;
  	IO():p1(buf),p2(buf),pp(pbuf){}
  	inline char gc() {
    	return getchar();
    	if (p1==p2) p2=(p1=buf)+fread(buf,1,MAXSIZE,stdin);
    	return p1==p2?' ':*p1++;
  	}
	inline bool blank(char ch) {return ch==' '||ch =='\n'||ch == '\r'||ch == '\t';}
  	template <class T>
  	inline void read(T &x)
	{
	    register double tmp=1;register bool sign=0; x=0;
	    register char ch=gc();
	    for (;!isdigit(ch);ch=gc()) if(ch=='-') sign=1;
	    for (;isdigit(ch);ch=gc()) x=x*10+(ch-'0');
	    if (ch=='.') for (ch=gc();isdigit(ch);ch=gc()) tmp/=10.0,x+=tmp*(ch-'0');
	    if (sign) x=-x;
  	}
  	inline void read(char *s)
	{
    	register char ch=gc();
		for (;blank(ch);ch=gc());
		for (;!blank(ch);ch=gc()) *s++=ch;
    	*s=0;
  	}
  	inline void read(char &c) {for(c=gc();blank(c);c=gc());}
  	template<class t> inline void write(t x){
		if(x<0) putchar('-'),write(-x);
		else{if(x>9) write(x/10);putchar('0'+x%10);}
	}
} io;

const int mod=1e9+7;
const int mo=998244353;
const int N=1e6+5;

int n,L,m,a[N];

inline void Add(int &x,int y)
{
	x+=y;
	if(x>=mod) x%=mod;
}

struct Node
{
	int a[105];
	Node(){mem(a,0);}
	inline Node friend operator * (Node &s,Node &t)
	{
		Node c;
		For(i,0,m-1) For(j,0,m-1) Add(c.a[(i+j)%m],s.a[i]*t.a[j]%mod);
		return c;
	}
};
Node A,B,C;

inline Node ksm(Node a,int y)
{
	Node ans;
	ans=a;
	y--;
	while(y)
	{
		if(y&1) ans=ans*a;
		a=a*a;
		y>>=1ll;
	}
	return ans;
}

signed main()
{
	io.read(n),io.read(L),io.read(m);
	For(i,1,n)
	{
		int x; io.read(x);
		A.a[x%m]++;
	}
	For(i,1,n)
	{
		int x; io.read(x);
		a[i]=x;
		B.a[x%m]++;
	}
	For(i,1,n)
	{
		int x; io.read(x);
		C.a[(x+a[i])%m]++;
	}
	Node ans;
	if(L>2)
	{
		ans=ksm(B,L-2);
		ans=ans*A;
		ans=ans*C;
	}
	else ans=A*C;
	int Ans=0;
	For(i,0,100) if(!(i%m))
	Add(Ans,ans.a[i]);
	io.write(Ans);
	return 0;
}


#include <bits/stdc++.h>
#define For(i,a,b) for ( int i=(a);i<=(b);i++ )
#define Dow(i,b,a) for ( int i=(b);i>=(a);i-- )
#define GO(i,x) for ( int i=head[x];i;i=e[i].nex )
#define mem(x,s) memset(x,s,sizeof(x))
#define cpy(x,s) memcpy(x,s,sizeof(x))
#define YES return puts("YES"),0
#define NO return puts("NO"),0
#define GG return puts("-1"),0
#define pb push_back
#define int long long
using namespace std;

struct IO
{
	#define MAXSIZE (1 << 20)
	#define isdigit(x) (x >= '0' && x <= '9')
  	char buf[MAXSIZE],*p1,*p2;
  	char pbuf[MAXSIZE],*pp;
  	IO():p1(buf),p2(buf),pp(pbuf){}
  	inline char gc() {
    	return getchar();
    	if (p1==p2) p2=(p1=buf)+fread(buf,1,MAXSIZE,stdin);
    	return p1==p2?' ':*p1++;
  	}
	inline bool blank(char ch) {return ch==' '||ch =='\n'||ch == '\r'||ch == '\t';}
  	template <class T>
  	inline void read(T &x)
	{
	    register double tmp=1;register bool sign=0; x=0;
	    register char ch=gc();
	    for (;!isdigit(ch);ch=gc()) if(ch=='-') sign=1;
	    for (;isdigit(ch);ch=gc()) x=x*10+(ch-'0');
	    if (ch=='.') for (ch=gc();isdigit(ch);ch=gc()) tmp/=10.0,x+=tmp*(ch-'0');
	    if (sign) x=-x;
  	}
  	inline void read(char *s)
	{
    	register char ch=gc();
		for (;blank(ch);ch=gc());
		for (;!blank(ch);ch=gc()) *s++=ch;
    	*s=0;
  	}
  	inline void read(char &c) {for(c=gc();blank(c);c=gc());}
  	template<class t> inline void write(t x){
		if(x<0) putchar('-'),write(-x);
		else{if(x>9) write(x/10);putchar('0'+x%10);}
	}
} io;

const int mod=1e9+7;
const int mo=998244353;
const int N=2e5+5;

int n,L,m,a[N];

inline void Add(int &x,int y)
{
	x+=y;
	if(x>=mod) x%=mod;
}

struct Node
{
	int a[105];
	Node(){mem(a,0);}
	inline Node friend operator * (Node &s,Node &t)
	{
		Node c;
		For(i,0,m-1) For(j,0,m-1) Add(c.a[(i+j)%m],s.a[i]*t.a[j]%mod);
		return c;
	}
};
Node A,B,C;

inline Node ksm(Node a,int y)
{
	Node ans;
	ans=a;
	y--;
	while(y)
	{
		if(y&1) ans=ans*a;
		a=a*a;
		y>>=1ll;
	}
	return ans;
}

signed main()
{
	io.read(n),io.read(L),io.read(m);
	For(i,1,n)
	{
		int x; io.read(x);
		A.a[x%m]++;
	}
	For(i,1,n)
	{
		int x; io.read(x);
		a[i]=x;
		B.a[x%m]++;
	}
	For(i,1,n)
	{
		int x; io.read(x);
		C.a[(x+a[i])%m]++;
	}
	Node ans;
	if(L>2)
	{
		ans=ksm(B,L-2);
		ans=ans*A;
		ans=ans*C;
	}
	else ans=A*C;
	int Ans=0;
	For(i,0,100) if(!(i%m))
	Add(Ans,ans.a[i]);
	io.write(Ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
const int Mod=1e9+7;
int n,m,mod,ans,A[N],B[N],C[N],D[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
struct node{
	int m[105][105];
}a,b,res;
node operator * (node a,node b)
{
	node c;
	for(int i=0;i<mod;i++)
		for(int j=0;j<mod;j++)c.m[i][j]=0;
	for(int i=0;i<mod;i++)
		for(int j=0;j<mod;j++)
			for(int k=0;k<mod;k++)c.m[i][j]=(c.m[i][j]+a.m[i][k]*b.m[k][j])%Mod;
	return c;
}
node kuai(node a,int b)
{
	for(int i=0;i<mod;i++)res.m[i][i]=1;
	while(b)
	{
		if(b&1)res=res*a;
		a=a*a;
		b=b/2;
	}
	return res;
}
signed main()
{
	n=read();m=read();mod=read();
	for(int i=1;i<=n;i++)
	{
		int x=read()%mod;
		A[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		int x=read()%mod;
		B[x]++;
		D[i]=x;
	}
	for(int i=1;i<=n;i++)
		C[i]=read();
	for(int i=0;i<mod;i++)
	{
		for(int j=0;j<mod;j++)
		{
			if(i>=j)a.m[i][j]=B[i-j];
			else a.m[i][j]=B[i+mod-j];
		}
	}
	a=kuai(a,m-2);
	for(int i=0;i<mod;i++)b.m[i][0]=A[i];
	a=a*b;
//	for(int i=0;i<mod;i++)cout<<a.m[i][0]<<endl;
	for(int i=0;i<mod;i++)
		for(int j=1;j<=n;j++)
			if((i+D[j]+C[j])%mod==0)
				ans=(ans+a.m[i][0])%Mod;
	cout<<ans;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=a; i<=b; i++)
typedef long long ll;
const ll base=1e9+7;
const ll mod=base*base*2;
const int N=1e6+4;
ll m;
struct matrix
{
    ll val[105][105];
    matrix(){memset(val,0,sizeof(0));}
    matrix operator * (const matrix & x)
    {
        matrix res;
        FOR(u,0,m-1) FOR(v,0,m-1)
        {
            FOR(i,0,m-1)
            {
                res.val[u][v]+=val[u][i]*x.val[i][v];
                if (res.val[u][v]>=mod) res.val[u][v]-=mod;
            }
            res.val[u][v]%=base;
        }
        return res;
    }
};
matrix mu(matrix a, ll n)
{
    matrix res;
    FOR(i,0,m-1) res.val[i][i]=1;
    while(n>0)
    {
        if(n&1) res=res*a;
        a=a*a;
        n>>=1;
    }
    return res;
}
ll n,l,c[N],v[N],x,ans;
matrix f,g;
int main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//    freopen("852b.inp","r",stdin);
//    freopen("852b.out","w",stdout);
    cin >> n >> l >> m;
    FOR(i,1,n)
    {
        cin >> x;
        x=x%m;
        g.val[0][x]++;
    }
    memset(c,0,sizeof(c));
    FOR(i,1,n)
    {
        cin >> v[i];
        v[i]=v[i]%m;
        c[v[i]]++;
    }
    FOR(i,0,m-1) FOR(j,0,m-1) f.val[i][(i+j)%m]=c[j];
    memset(c,0,sizeof(c));
    FOR(i,1,n)
    {
        cin >> x;
        c[(x+v[i])%m]++;
    }
    f=mu(f,l-2);
    g=g*f;
//    FOR(i,0,m-1)
//    {
//        FOR(j,0,m-1) cout << g.val[i][j] << " ";
//        cout << endl;
//    }
    FOR(i,0,m-1) if(c[i]) ans=(ans+g.val[0][(m-i)%m]*c[i]%base)%base;
    cout << ans;
}


#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=a; i<=b; i++)
typedef long long ll;
const ll base=1e9+7;
const ll mod=base*base*7;
const int N=1e6+4;
ll m;
struct matrix
{
    ll val[105][105];
    matrix(){memset(val,0,sizeof(val));}
    matrix operator * (const matrix & x)
    {
        matrix res;
        FOR(u,0,m-1) FOR(v,0,m-1)
        {
            FOR(i,0,m-1)
            {
                res.val[u][v]+=val[u][i]*x.val[i][v];
                if (res.val[u][v]>=mod) res.val[u][v]-=mod;
            }
            res.val[u][v]%=base;
        }
        return res;
    }
};
matrix mu(matrix a, ll n)
{
    matrix res;
    FOR(i,0,m-1) res.val[i][i]=1;
    while(n>0)
    {
        if(n&1) res=res*a;
        a=a*a;
        n>>=1;
    }
    return res;
}
ll n,l,c[N],v[N],x,ans;
matrix f,g;
int main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//    freopen("852b.inp","r",stdin);
//    freopen("852b.out","w",stdout);
    cin >> n >> l >> m;
    FOR(i,1,n)
    {
        cin >> x;
        x=x%m;
        g.val[0][x]++;
    }
    memset(c,0,sizeof(c));
    FOR(i,1,n)
    {
        cin >> v[i];
        v[i]=v[i]%m;
        c[v[i]]++;
    }

    FOR(i,0,m-1) FOR(j,0,m-1) f.val[i][(i+j)%m]=c[j];
    memset(c,0,sizeof(c));
    FOR(i,1,n)
    {
        cin >> x;
        c[(x+v[i])%m]++;
    }
    f=mu(f,l-2);
    g=g*f;
    FOR(i,0,m-1) if(c[i]) ans=(ans+g.val[0][(m-i)%m]*c[i]%base)%base;
    cout << ans;
}


#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=a; i<=b; i++)
typedef long long ll;
const ll base=1e9+7;
const ll mod=base*base*2;
const int N=1e6+4;
ll m;
struct matrix
{
    ll val[105][105];
    matrix(){memset(val,0,sizeof(0));}
    matrix operator * (const matrix & x)
    {
        matrix res;
        FOR(u,0,m-1) FOR(v,0,m-1)
        {
            FOR(i,0,m-1)
            {
                res.val[u][v]+=val[u][i]*x.val[i][v];
                if (res.val[u][v]>=mod) res.val[u][v]-=mod;
            }
            res.val[u][v]%=base;
        }
        return res;
    }
};
matrix mu(matrix a, ll n)
{
    matrix res;
    FOR(i,0,m-1) res.val[i][i]=1;
    while(n>0)
    {
        if(n&1) res=res*a;
        a=a*a;
        n>>=1;
    }
    return res;
}
ll n,l,c[N],v[N],x,ans;
matrix f,g;
int main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//    freopen("852b.inp","r",stdin);
//    freopen("852b.out","w",stdout);
    cin >> n >> l >> m;
    FOR(i,1,n)
    {
        cin >> x;
        x=x%m;
        g.val[0][x]++;
    }
    memset(c,0,sizeof(c));
    FOR(i,1,n)
    {
        cin >> v[i];
        v[i]=v[i]%m;
        c[v[i]]++;
    }
    FOR(i,0,m-1) FOR(j,0,m-1) f.val[i][(i+j)%m]=c[j];
    memset(c,0,sizeof(c));
    FOR(i,1,n)
    {
        cin >> x;
        c[(x+v[i])%m]++;
    }
    f=mu(f,l-2);
    g=g*f;
    FOR(i,0,m) if(c[i]) ans=(ans+g.val[0][m-i]*c[i]%base)%base;
    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;
inline void read(int &x){
    char ch;
    bool flag=false;
    for (ch=getchar();!isdigit(ch);ch=getchar())if (ch=='-') flag=true;
    for (x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());
    x=flag?-x:x;
}

inline void read(long long &x){
    char ch;
    bool flag=false;
    for (ch=getchar();!isdigit(ch);ch=getchar())if (ch=='-') flag=true;
    for (x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());
    x=flag?-x:x;
}

inline void write(int x){
    static const int maxlen=100;
    static char s[maxlen];
        if (x<0) {   putchar('-'); x=-x;}
    if(!x){ putchar('0'); return; }
    int len=0; for(;x;x/=10) s[len++]=x % 10+'0';
    for(int i=len-1;i>=0;--i) putchar(s[i]);
}

const int MAXN = 1100000;

int tot,l,lim;
int v[ MAXN ];
long long cnt[ 200 ];

struct Matrix{
int n,m;
long long a[120][120];
Matrix (){
    memset( a, 0 ,sizeof( a )) ;
    n=0,m=0;
}

void out(){
    puts("");
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<m;j++)
            printf("%d ",a[i][j]);
        puts("");
    }
    puts("");
}

void init(){
    memset(cnt , 0 ,sizeof( cnt ));
    for (int i = 1;i<=tot;i++)
        {
            int x;
            read(x);
            x=x%lim;
            v[i]=x;
            cnt[x]++;
        }
    n=lim;  m=lim;
    for (int i=0;i<lim;i++)
        for (int j=0;j<lim;j++)
            a[ i ][ (i+j)%lim  ]=cnt[j];
    }
};

const long long P=1000000007ll;

Matrix operator * ( Matrix A, Matrix B ){
Matrix C;
C.n=A.n; C.m=B.m;
for (int i=0;i<A.n;i++)
    for (int j=0;j<A.m;j++)
        for (int k=0;k<B.m;k++)
            C.a[i][k]= ( C.a[i][k] + 1ll*A.a[i][j] * B.a[j][k]%P )%P;
return C;
}

Matrix st,mid,ORG;

Matrix get_pow( Matrix A ,int x){
if (x==0)
    return ORG;
Matrix tmp=get_pow( A ,x/2);
if ( x%2==0 )
    return tmp*tmp;
else
    return tmp*tmp*A;
}

int main(){
    read(tot); read(l); read(lim);
    ORG.n=lim;ORG.m=lim;
    for (int i = 0;i<lim;i++)
        ORG.a[i][i]=1;

    st.n=1; st.m=lim;
    for (int i = 1;i<=tot;i++)
        {
            int x;
            read(x);
            x=x%lim;
            st.a[0][x]++;
        }

    mid.init();
    memset(cnt,0,sizeof(cnt));
    for (int i = 1;i<=tot;i++)
        {
            int x;
            read(x);
            cnt[ ( x + v[i] ) % lim ] ++;
        }

    mid=get_pow(mid,l-2);
    //mid.out();
    st=st*mid;
    int ans=0;
    for (int i=0;i<lim;i++)
        if ( cnt [ i ] )
            ans= ( ans + 1ll*st.a[0][ ( lim-i)%lim ]*cnt[ i ]%P )%P;
    printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=a; i<=b; i++)
typedef long long ll;
const ll base=1e9+7;
const ll mod=base*base*2;
const int N=1e6+4;
ll m;
struct matrix
{
    ll val[105][105];
    matrix(){memset(val,0,sizeof(0));}
    matrix operator * (const matrix & x)
    {
        matrix res;
        FOR(u,0,m-1) FOR(v,0,m-1)
        {
            FOR(i,0,m-1)
            {
                res.val[u][v]+=val[u][i]*x.val[i][v];
                if (res.val[u][v]>=mod) res.val[u][v]-=mod;
            }
            res.val[u][v]%=base;
        }
        return res;
    }
};
matrix mu(matrix a, ll n)
{
    matrix res;
    FOR(i,0,m-1) res.val[i][i]=1;
    while(n>0)
    {
        if(n&1) res=res*a;
        a=a*a;
        n>>=1;
    }
    return res;
}
ll n,l,c[N],v[N],x,ans;
matrix f,g;
int main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//    freopen("852b.inp","r",stdin);
//    freopen("852b.out","w",stdout);
    cin >> n >> l >> m;
    FOR(i,1,n)
    {
        cin >> x;
        x=x%m;
        g.val[0][x]++;
    }
    memset(c,0,sizeof(c));
    FOR(i,1,n)
    {
        cin >> v[i];
        v[i]=v[i]%m;
        c[v[i]]++;
    }
    FOR(i,0,m-1) FOR(j,0,m-1) f.val[i][(i+j)%m]=c[j];
    memset(c,0,sizeof(c));
    FOR(i,1,n)
    {
        cin >> x;
        c[(x+v[i])%m]++;
    }
    f=mu(f,l-2);
    g=g*f;
    FOR(i,0,m-1)
    {
        FOR(j,0,m-1) cout << g.val[i][j] << " ";
        cout << endl;
    }
    FOR(i,0,m-1) if(c[i]) ans=(ans+g.val[0][(m-i)%m]*c[i]%base)%base;
    cout << ans;
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e6+5, M = 1e2+5, P = 1e9+7;
int n, l, m;
struct Matrix
{
    int __[M][M];
    int* operator [] (const int _) { return __[_]; }
    Matrix() { memset(__, 0, sizeof(__)); }
    Matrix operator * (const Matrix &_) const
    {
        Matrix ret;
        for(int i = 0; i < m; ++i)
            for(int j = 0; j < m; ++j)
                for(int k = 0; k < m; ++k)
                    ret[i][j] = (ret[i][j]+1ll*__[i][k]*_.__[k][j]%P)%P;
        return ret;
    }
    void set() { for(int i = 0; i < m; ++i) __[i][i] = 1; }
}f, g;
int a[N], b[N], c[N], ans;
Matrix qpow(Matrix a, int b)
{
    Matrix ret; ret.set();
    for( ; b; b >>= 1, a = a*a) if(b&1) ret = ret*a;
    return ret;
}
int main()
{
    n = read(), l = read(), m = read();
    for(int i = 1; i <= n; ++i) a[i] = read(), ++f[0][a[i]%m];
    for(int i = 1; i <= n; ++i) b[i] = read();
    for(int i = 1; i <= n; ++i) c[i] = read();
    for(int i = 0; i < m; ++i)
        for(int j = 1; j <= n; ++j)
            ++g[i][(i+b[j])%m];
    f = f*qpow(g, l-2);
    for(int i = 1; i <= n; ++i)
        ans = (ans+f[0][(m-(b[i]+c[i])%m)%m])%P;
    printf("%d\n", ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 1e6 + 5, mod = 1e9 + 7;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch^48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
int n, l, m, ct[N];
struct node {
	LL v[105];
	node() {memset(v, 0, sizeof(v));}
	node operator * (node b) {
		node res;
		for(int i = 0; i < m; ++ i) {
			for(int j = 0; j < m; ++ j) {
				(res.v[(i + j) % m] += v[i] * b.v[j]) %= mod;
			}
		}
		return res;
	}
} e, s, t;
node ksm(node x, int y) {
	node res; res.v[0] = 1;
	for( ; y; x = x * x, y >>= 1) {
		if(y & 1) res = res * x;
	}
	return res;
}
int main() {
	n = read(); l = read(); m = read();
	for(int i = 1; i <= n; ++ i) s.v[read() % m] ++;
	for(int i = 1; i <= n; ++ i) e.v[(ct[i] = read()) % m] ++;
	for(int i = 1; i <= n; ++ i) t.v[(read() + ct[i]) % m] ++;
	if(l > 2) s = s * ksm(e, l - 2); s = s * t;
	printf("%lld\n", s.v[0]);
	return 0;
}


#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF LLONG_MAX
#define INF INT_MAX
#define EPS 1e-9
#define MOD 1000000007
#define MAXN 1000010
using namespace std;
struct mat {
    int m[210][210];
    int n;
    mat(int N)
    {
        memset(m,0,sizeof(m));
        n = N;
    }
};
mat I(210), B(210);
mat operator*(mat &a, mat &b) {
    int n = a.n;
    mat c(n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                lld dodati = (a.m[i][k]*1LL * b.m[k][j]);
                if(dodati >= MOD) dodati%= MOD;
                c.m[i][j] += dodati;
                if(c.m[i][j] >= MOD) c.m[i][j] %= MOD;
            }
        }
    }
    return c;
}
mat operator^(mat &a, lld k) {
    mat c(a.n);
    c = I;
    while(k > 0) {
        if(k&1) {
            c = c*a;
        }
        k /= 2;
        a = a*a;
    }
    return c;
}
int n;
lld k;
vector<int> state;
vector<int> operator*(vector<int> &v, mat a) {
    int n = sz(v);
    vector<int> rez;
    for(int i = 0; i < n; i++) {
        lld sum = 0;
        for(int j = 0; j < n; j++) {
            sum += (1LL * v[j] * a.m[j][i])%MOD;
            if(sum >= MOD)sum %= MOD;
        }
        rez.pb(sum);
    }
    return rez;
}
int a[MAXN], b[MAXN], c[MAXN], cnt[210];
int main() {
    int n, l, m; scanf("%d%d%d", &n, &l, &m);
    for(int i = 0; i < m; i++) state.pb(0);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]), state[a[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &b[i]), cnt[b[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &c[i]);
    //STIZE(1);
    //for(int i = 0; i < 210; i++) state.pb(0);
    for(int i = 0; i < m; i++) I.m[i][i] = 1;
    for(int i = 0; i < m; i++) {
        for(int j = 0; j < m; j++) {
            int idx = (m+j-i)%m;
            B.m[i][j] = cnt[idx];
        }
    }
    //STIZE(2);
    state = state*(B^(l-2));
    //STIZE(3);
    int rez = 0;
    for(int i = 0; i < n; i++) {
        int cur = (c[i]+b[i])%m;
        rez += state[(m-cur)%m];
        rez %= MOD;
    }
    printf("%d", rez);
    return 0;
}


#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF LLONG_MAX
#define INF INT_MAX
#define EPS 1e-9
#define MOD 1000000007
#define MAXN 1000010
using namespace std;
struct mat {
    int m[210][210];
    int n;
    mat(int N)
    {
        memset(m,0,sizeof(m));
        n = N;
    }
};
mat I(210), B(210);
mat operator*(mat &a, mat &b) {
    int n = a.n;
    mat c(n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                c.m[i][j] += (a.m[i][k]*1LL * b.m[k][j])%MOD;
                if(c.m[i][j] > MOD) c.m[i][j] %= MOD;
            }
        }
    }
    return c;
}
mat operator^(mat &a, lld k) {
    mat c(a.n);
    c = I;
    while(k > 0) {
        if(k&1) {
            c = c*a;
        }
        k /= 2;
        a = a*a;
    }
    return c;
}
int n;
lld k;
vector<int> state;
vector<int> operator*(vector<int> &v, mat &a) {
    int n = sz(v);
    vector<int> rez;
    for(int i = 0; i < n; i++) {
        lld sum = 0;
        for(int j = 0; j < n; j++) {
            sum += (1LL * v[j] * a.m[j][i])%MOD;
            if(sum > MOD)sum %= MOD;
        }
        rez.pb(sum);
    }
    return rez;
}
int a[MAXN], b[MAXN], c[MAXN], cnt[210];
int main() {
    int n, l, m; scanf("%d%d%d", &n, &l, &m);
    for(int i = 0; i < m; i++) state.pb(0);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]), state[a[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &b[i]), cnt[b[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &c[i]);
    //STIZE(1);
    //for(int i = 0; i < 210; i++) state.pb(0);
    for(int i = 0; i < m; i++) I.m[i][i] = 1;
    for(int i = 0; i < m; i++) {
        for(int j = 0; j < m; j++) {
            int idx = (m+j-i)%m;
            B.m[i][j] = cnt[idx];
        }
    }
    //STIZE(2);
    state = state*(B^(l-2));
    //STIZE(3);
    int rez = 0;
    for(int i = 0; i < n; i++) {
        int cur = (c[i]+b[i])%m;
        rez += state[(m-cur)%m];
        rez %= MOD;
    }
    printf("%d", rez);
    return 0;
}


#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF LLONG_MAX
#define INF INT_MAX
#define EPS 1e-9
#define MOD 1000000007
#define MAXN 1000010
using namespace std;
struct mat {
    int m[210][210];
    int n;
    mat(int N)
    {
        memset(m,0,sizeof(m));
        n = N;
    }
};
mat I(210), B(210);
mat operator*(mat a, mat b) {
    int n = a.n;
    mat c(n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                c.m[i][j] += (a.m[i][k]*1LL * b.m[k][j])%MOD;
                if(c.m[i][j] > MOD) c.m[i][j] %= MOD;
            }
        }
    }
    return c;
}
mat operator^(mat a, lld k) {
    mat c(a.n);
    c = I;
    while(k > 0) {
        if(k&1) {
            c = c*a;
        }
        k /= 2;
        a = a*a;
    }
    return c;
}
int n;
lld k;
vector<int> state;
vector<int> operator*(vector<int> &v, mat a) {
    int n = sz(v);
    vector<int> rez;
    for(int i = 0; i < n; i++) {
        lld sum = 0;
        for(int j = 0; j < n; j++) {
            sum += (1LL * v[j] * a.m[j][i])%MOD;
            if(sum > MOD)sum %= MOD;
        }
        rez.pb(sum);
    }
    return rez;
}
int a[MAXN], b[MAXN], c[MAXN], cnt[210];
int main() {
    int n, l, m; scanf("%d%d%d", &n, &l, &m);
    for(int i = 0; i < 210; i++) state.pb(0);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]), state[a[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &b[i]), cnt[b[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &c[i]);
    //STIZE(1);
    //for(int i = 0; i < 210; i++) state.pb(0);
    for(int i = 0; i < 210; i++) I.m[i][i] = 1;
    for(int i = 0; i < m; i++) {
        for(int j = 0; j < m; j++) {
            int idx = (m+j-i)%m;
            B.m[i][j] = cnt[idx];
        }
    }
    //STIZE(2);
    state = state*(B^(l-2));
    //STIZE(3);
    int rez = 0;
    for(int i = 0; i < n; i++) {
        int cur = (c[i]+b[i])%m;
        rez += state[(m-cur)%m];
    }
    printf("%d", rez);
    return 0;
}


#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF LLONG_MAX
#define INF INT_MAX
#define EPS 1e-9
#define MOD 1000000007
#define MAXN 1000010
using namespace std;
struct mat {
    int m[210][210];
    int n;
    mat(int N)
    {
        memset(m,0,sizeof(m));
        n = N;
    }
};
mat I(210), B(210);
mat operator*(mat &a, mat &b) {
    int n = a.n;
    mat c(n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                c.m[i][j] += (a.m[i][k]*1LL * b.m[k][j])%MOD;
                if(c.m[i][j] > MOD) c.m[i][j] %= MOD;
            }
        }
    }
    return c;
}
mat operator^(mat &a, lld k) {
    mat c(a.n);
    c = I;
    while(k > 0) {
        if(k&1) {
            c = c*a;
        }
        k /= 2;
        a = a*a;
    }
    return c;
}
int n;
lld k;
vector<int> state;
vector<int> operator*(vector<int> &v, mat a) {
    int n = sz(v);
    vector<int> rez;
    for(int i = 0; i < n; i++) {
        lld sum = 0;
        for(int j = 0; j < n; j++) {
            sum += (1LL * v[j] * a.m[j][i])%MOD;
            if(sum > MOD)sum %= MOD;
        }
        rez.pb(sum);
    }
    return rez;
}
int a[MAXN], b[MAXN], c[MAXN], cnt[210];
int main() {
    int n, l, m; scanf("%d%d%d", &n, &l, &m);
    for(int i = 0; i < m; i++) state.pb(0);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]), state[a[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &b[i]), cnt[b[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &c[i]);
    //STIZE(1);
    //for(int i = 0; i < 210; i++) state.pb(0);
    for(int i = 0; i < m; i++) I.m[i][i] = 1;
    for(int i = 0; i < m; i++) {
        for(int j = 0; j < m; j++) {
            int idx = (m+j-i)%m;
            B.m[i][j] = cnt[idx];
        }
    }
    //STIZE(2);
    state = state*(B^(l-2));
    //STIZE(3);
    int rez = 0;
    for(int i = 0; i < n; i++) {
        int cur = (c[i]+b[i])%m;
        rez += state[(m-cur)%m];
        rez %= MOD;
    }
    printf("%d", rez);
    return 0;
}


#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF LLONG_MAX
#define INF INT_MAX
#define EPS 1e-9
#define MOD 1000000007
#define MAXN 1000010
using namespace std;
struct mat {
    int m[210][210];
    int n;
    mat(int N)
    {
        memset(m,0,sizeof(m));
        n = N;
    }
};
mat I(210), B(210);
mat operator*(mat a, mat b) {
    int n = a.n;
    mat c(n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                c.m[i][j] += (a.m[i][k]*1LL * b.m[k][j])%MOD;
                if(c.m[i][j] > MOD) c.m[i][j] %= MOD;
            }
        }
    }
    return c;
}
mat operator^(mat a, lld k) {
    mat c(a.n);
    c = I;
    while(k > 0) {
        if(k&1) {
            c = c*a;
        }
        k /= 2;
        a = a*a;
    }
    return c;
}
int n;
lld k;
vector<int> state;
vector<int> operator*(vector<int> &v, mat a) {
    int n = sz(v);
    vector<int> rez;
    for(int i = 0; i < n; i++) {
        lld sum = 0;
        for(int j = 0; j < n; j++) {
            sum += (1LL * v[j] * a.m[j][i])%MOD;
            if(sum > MOD)sum %= MOD;
        }
        rez.pb(sum);
    }
    return rez;
}
int a[MAXN], b[MAXN], c[MAXN], cnt[210];
int main() {
    int n, l, m; scanf("%d%d%d", &n, &l, &m);
    for(int i = 0; i < 210; i++) state.pb(0);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]), state[a[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &b[i]), cnt[b[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &c[i]);
    //STIZE(1);
    mat Bi = mat(210);
    //for(int i = 0; i < 210; i++) state.pb(0);
    for(int i = 0; i < 210; i++) I.m[i][i] = 1;
    for(int i = 0; i < 210; i++) {
        for(int j = 0; j < 210; j++) {
            int idx = (m+j-i)%m;
            B.m[i][j] = cnt[idx];
        }
    }
    Bi = B;
    //STIZE(2);
    state = state*(Bi^(l-2));
    //STIZE(3);
    int rez = 0;
    for(int i = 0; i < n; i++) {
        int cur = (c[i]+b[i])%m;
        rez += state[(m-cur)%m];
    }
    printf("%d", rez);
    return 0;
}


#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF LLONG_MAX
#define INF INT_MAX
#define EPS 1e-9
#define MOD 1000000007
#define MAXN 1000010
using namespace std;
struct mat {
    int m[210][210];
    int n;
    mat(int N)
    {
        memset(m,0,sizeof(m));
        n = N;
    }
};
mat I(210), B(210);
mat operator*(mat a, mat b) {
    int n = a.n;
    mat c(n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                c.m[i][j] += (a.m[i][k]*1LL * b.m[k][j])%MOD;
                if(c.m[i][j] > MOD) c.m[i][j] %= MOD;
            }
        }
    }
    return c;
}
mat operator^(mat a, lld k) {
    mat c(a.n);
    c = I;
    while(k > 0) {
        if(k&1) {
            c = c*a;
        }
        k /= 2;
        a = a*a;
    }
    return c;
}
int n;
lld k;
vector<int> state;
vector<int> operator*(vector<int> &v, mat a) {
    int n = sz(v);
    vector<int> rez;
    for(int i = 0; i < n; i++) {
        lld sum = 0;
        for(int j = 0; j < n; j++) {
            sum += (1LL * v[j] * a.m[j][i])%MOD;
            if(sum > MOD)sum %= MOD;
        }
        rez.pb(sum);
    }
    return rez;
}
int a[MAXN], b[MAXN], c[MAXN], cnt[210];
int main() {
    int n, l, m; scanf("%d%d%d", &n, &l, &m);
    for(int i = 0; i < m; i++) state.pb(0);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]), state[a[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &b[i]), cnt[b[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &c[i]);
    //STIZE(1);
    //for(int i = 0; i < 210; i++) state.pb(0);
    for(int i = 0; i < m; i++) I.m[i][i] = 1;
    for(int i = 0; i < m; i++) {
        for(int j = 0; j < m; j++) {
            int idx = (m+j-i)%m;
            B.m[i][j] = cnt[idx];
        }
    }
    //STIZE(2);
    state = state*(B^(l-2));
    //STIZE(3);
    int rez = 0;
    for(int i = 0; i < n; i++) {
        int cur = (c[i]+b[i])%m;
        rez += state[(m-cur)%m];
        rez %= MOD;
    }
    printf("%d", rez);
    return 0;
}


#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF LLONG_MAX
#define INF INT_MAX
#define EPS 1e-9
#define MOD 1000000007
#define MAXN 1000010
using namespace std;
struct mat {
    int m[210][210];
    int n;
    mat(int N)
    {
        memset(m,0,sizeof(m));
        n = N;
    }
};
mat I(210), B(210);
mat operator*(mat a, mat b) {
    int n = a.n;
    mat c(n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                c.m[i][j] += (a.m[i][k]*1LL * b.m[k][j])%MOD;
                if(c.m[i][j] > MOD) c.m[i][j] %= MOD;
            }
        }
    }
    return c;
}
mat operator^(mat a, lld k) {
    mat c(a.n);
    c = I;
    while(k > 0) {
        if(k&1) {
            c = c*a;
        }
        k /= 2;
        a = a*a;
    }
    return c;
}
int n;
lld k;
vector<int> state;
vector<int> operator*(vector<int> &v, mat a) {
    int n = sz(v);
    vector<int> rez;
    for(int i = 0; i < n; i++) {
        lld sum = 0;
        for(int j = 0; j < n; j++) {
            sum += (1LL * v[j] * a.m[j][i])%MOD;
            if(sum > MOD)sum %= MOD;
        }
        rez.pb(sum);
    }
    return rez;
}
int a[MAXN], b[MAXN], c[MAXN], cnt[210];
int main() {
    int n, l, m; scanf("%d%d%d", &n, &l, &m);
    for(int i = 0; i < m; i++) state.pb(0);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]), state[a[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &b[i]), cnt[b[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &c[i]);
    //STIZE(1);
    //for(int i = 0; i < 210; i++) state.pb(0);
    for(int i = 0; i < 210; i++) I.m[i][i] = 1;
    for(int i = 0; i < m; i++) {
        for(int j = 0; j < m; j++) {
            int idx = (m+j-i)%m;
            B.m[i][j] = cnt[idx];
        }
    }
    //STIZE(2);
    state = state*(B^(l-2));
    //STIZE(3);
    int rez = 0;
    for(int i = 0; i < n; i++) {
        int cur = (c[i]+b[i])%m;
        rez += state[(m-cur)%m];
    }
    printf("%d", rez);
    return 0;
}


#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF LLONG_MAX
#define INF INT_MAX
#define EPS 1e-9
#define MOD 1000000007
#define MAXN 1000010
using namespace std;
struct mat {
    int m[210][210];
    int n;
    mat(int N)
    {
        memset(m,0,sizeof(m));
        n = N;
    }
};
mat I(210), B(210);
mat operator*(mat a, mat b) {
    int n = a.n;
    mat c(n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                c.m[i][j] += (a.m[i][k]*1LL * b.m[k][j])%MOD;
                if(c.m[i][j] > MOD) c.m[i][j] %= MOD;
            }
        }
    }
    return c;
}
mat operator^(mat a, lld k) {
    mat c(a.n);
    c = I;
    while(k > 0) {
        if(k&1) {
            c = c*a;
        }
        k /= 2;
        a = a*a;
    }
    return c;
}
int n;
lld k;
vector<int> state;
vector<int> operator*(vector<int> &v, mat a) {
    int n = sz(v);
    vector<int> rez;
    for(int i = 0; i < n; i++) {
        lld sum = 0;
        for(int j = 0; j < n; j++) {
            sum += (1LL * v[j] * a.m[j][i])%MOD;
            if(sum > MOD)sum %= MOD;
        }
        rez.pb(sum);
    }
    return rez;
}
int a[MAXN], b[MAXN], c[MAXN], cnt[210];
int main() {
    int n, l, m; scanf("%d%d%d", &n, &l, &m);
    for(int i = 0; i < m; i++) state.pb(0);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]), state[a[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &b[i]), cnt[b[i]%m]++;
    for(int i = 0; i < n; i++) scanf("%d", &c[i]);
    //STIZE(1);
    //for(int i = 0; i < 210; i++) state.pb(0);
    for(int i = 0; i < m; i++) I.m[i][i] = 1;
    for(int i = 0; i < m; i++) {
        for(int j = 0; j < m; j++) {
            int idx = (m+j-i)%m;
            B.m[i][j] = cnt[idx];
        }
    }
    //STIZE(2);
    state = state*(B^(l-2));
    //STIZE(3);
    int rez = 0;
    for(int i = 0; i < n; i++) {
        int cur = (c[i]+b[i])%m;
        rez += state[(m-cur)%m];
    }
    printf("%d", rez);
    return 0;
}


//This disgusting code is wriiten by Juruo D0zingbear
//Please don't hack me! 0v0 <3
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}

// cf IO: I64d
// atcoder IO: ����
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int Maxn=1e6+5;
const long long mod=1e9+7;
int st[Maxn],End[Maxn],mid[Maxn];
int n,l,m;
struct matrix{
	int x,y;
	long long mat[105][105];
	matrix(int a,int b){
		x=a,y=b;
		for (int i=0;i<x;i++){
			for (int j=0;j<y;j++){
				mat[i][j]=0LL;
			}
		}
	}
	void clear(){
		for (int i=0;i<x;i++){
			for (int j=0;j<y;j++){
				mat[i][j]=0LL;
			}
		}
	}
	void _debug(){
		for (int i=0;i<x;i++){
			for (int j=0;j<y;j++){
				printf("%I64d ",mat[i][j]);
			}
			printf("\n");
		}
	}
	void I(){
		for (int i=0;i<m;i++) mat[i][i]=1;
	}
};
matrix mult(matrix a,matrix b){
	matrix c(a.x,b.y);
	for (int i=0;i<a.x;i++){
		for (int j=0;j<b.y;j++){
			for (int k=0;k<a.y;k++){
				c.mat[i][j]+=a.mat[i][k]*b.mat[k][j];
				c.mat[i][j]%=mod;
			}
		}
	}
	return c;
}
matrix qp(matrix x,int p){
	if (p==1){
		return x;
	}
	if (p==0){
		matrix tmp(m,m);
		tmp.I();
		return tmp;
	}
	if (p%2==0){
		matrix y=qp(x,p/2);
		return mult(y,y);
	}
	else{
		matrix y=qp(x,p/2);
		return mult(y,mult(y,x));
	}
}
int cnt[105],cnt2[105];
int main(){
	scanf("%d %d %d",&n,&l,&m);
	for (int i=0;i<n;i++){
		scanf("%d",&st[i]);
	}
	for (int i=0;i<n;i++){
		scanf("%d",&mid[i]);
		cnt[mid[i]]++;
	}
	for (int i=0;i<n;i++){
		scanf("%d",&End[i]);
		cnt2[(mid[i]+End[i])%m]++;
	}
	//cout<<cnt2[5]<<endl;
	matrix ini(m,1);
	for (int i=0;i<n;i++){
		ini.mat[st[i]][0]++;
	}
	//ini._debug();
	matrix trans(m,m);
	for (int i=0;i<m;i++){
		for (int j=0;j<m;j++){
			trans.mat[i][(i+j)%m]+=cnt[j];
		}
	}
	matrix tmpp(m,m);
	//ini._debug();
	tmpp=qp(trans,l-2);

	//tmpp._debug();
	ini=mult(tmpp,ini);
	//ini._debug();
	trans.clear();
	for (int i=0;i<m;i++){
		for (int j=0;j<m;j++){
			trans.mat[i][(i+j)%m]+=cnt2[j];
		}
	}
	//trans._debug();

	ini=mult(trans,ini);
	printf("%I64d\n",ini.mat[0][0]);
	return 0;
}


//This disgusting code is wriiten by Juruo D0zingbear
//Please don't hack me! 0v0 <3
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}

// cf IO: I64d
// atcoder IO: ｌｌｄ
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int Maxn=1e6+5;
const long long mod=1e9+7;
int st[Maxn],End[Maxn],mid[Maxn];
int n,l,m;
struct matrix{
	int x,y;
	long long mat[105][105];
	matrix(int a,int b){
		x=a,y=b;
		for (int i=0;i<x;i++){
			for (int j=0;j<y;j++){
				mat[i][j]=0LL;
			}
		}
	}
	void clear(){
		for (int i=0;i<x;i++){
			for (int j=0;j<y;j++){
				mat[i][j]=0LL;
			}
		}
	}
	void _debug(){
		for (int i=0;i<x;i++){
			for (int j=0;j<y;j++){
				printf("%I64d ",mat[i][j]);
			}
			printf("\n");
		}
		cout<<"end"<<endl;
	}
	void I(){
		for (int i=0;i<m;i++) mat[i][i]=1;
	}
};
matrix mult(matrix a,matrix b){
	matrix c(a.x,b.y);
	for (int i=0;i<a.x;i++){
		for (int j=0;j<b.y;j++){
			for (int k=0;k<a.y;k++){
				c.mat[i][j]+=a.mat[i][k]*b.mat[k][j];
				c.mat[i][j]%=mod;
			}
		}
	}
	return c;
}
matrix qp(matrix x,int p){
	if (p==1){
		return x;
	}
	if (p==0){
		matrix tmp(m,m);
		tmp.I();
		return tmp;
	}
	if (p%2==0){
		matrix y=qp(x,p/2);
		return mult(y,y);
	}
	else{
		matrix y=qp(x,p/2);
		return mult(y,mult(y,x));
	}
}
int cnt[105],cnt2[105];
int main(){
	scanf("%d %d %d",&n,&l,&m);
	for (int i=0;i<n;i++){
		scanf("%d",&st[i]);
	}
	for (int i=0;i<n;i++){
		scanf("%d",&mid[i]);
		cnt[mid[i]]++;
	}
	for (int i=0;i<n;i++){
		scanf("%d",&End[i]);
		cnt2[(mid[i]+End[i])%m]++;
	}
	//cout<<cnt2[5]<<endl;
	matrix ini(m,1);
	for (int i=0;i<n;i++){
		ini.mat[st[i]][0]++;
	}
	//ini._debug();
	matrix trans(m,m);
	for (int i=0;i<m;i++){
		for (int j=0;j<m;j++){
			trans.mat[(i+j)%m][i]+=cnt[j];
		}
	}
	matrix tmpp(m,m);

	tmpp=qp(trans,l-2);

	//tmpp._debug();
	ini=mult(tmpp,ini);
	//ini._debug();
	trans.clear();
	for (int i=0;i<m;i++){
		for (int j=0;j<m;j++){
			trans.mat[(i+j)%m][i]+=cnt2[j];
		}
	}
	//trans._debug();

	ini=mult(trans,ini);
//	ini._debug();
	printf("%I64d\n",ini.mat[0][0]);
	return 0;
}
/*
2 3 13
4 6
2 1
3 4
*/


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <cstring>
#include <stack>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <tuple>
using namespace std;

#define M (1000000007)
#define N (1000*1000+10)
int n, l, m;
int cost[2][N];
map<int, int> cm;

int gcd(int a, int b) {
	return b == 1 ? a : gcd(b, a%b);
}

void read_data() {
	cin >> n >> l >> m;
	for (int i = 0; i < n; i++)
		scanf("%d", &cost[0][i]);
	int ai;
	for (int i = 0; i < n; i++) {
		scanf("%d", &ai);
		cm[ai]++;
	}
	for (int i = 0; i < n; i++)
		scanf("%d", &cost[1][i]);
}

int deal() {
	vector<int> dp[2];
	dp[0].assign(m, 0);
	int now = 0;
	for (int i = 0; i < n; i++) {
		int x = (cost[0][i] + cost[1][i]) % m;
		dp[now][x] += 1;
	}
	int next;
	for (int k = 1; k < l; k++) {
		next = 1-now;
		dp[next].assign(m, 0);
		for (int i = 0; i < m; i++)
			for (auto &v : cm) {
				int ni = (i + v.first) %  m;
				dp[next][ni] += (dp[now][i]*v.second)%M;
			}
		now = next;
	}
	return dp[now][0];
}

int main() {
	read_data();
	cout << deal() << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <cstring>
#include <stack>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <tuple>
using namespace std;

#define M (1000000007)
#define N (1000*1000+10)
int n, l, m;
int cost[2][N];
map<int, int> cm;

int gcd(int a, int b) {
	return b == 1 ? a : gcd(b, a%b);
}

void read_data() {
	cin >> n >> l >> m;
	for (int i = 0; i < n; i++)
		scanf("%d", &cost[0][i]);
	int ai;
	for (int i = 0; i < n; i++) {
		scanf("%d", &ai);
		cm[ai]++;
	}
	for (int i = 0; i < n; i++)
		scanf("%d", &cost[1][i]);
}

int deal() {
	vector<int> dp[2];
	dp[0].assign(m, 0);
	int now = 0;
	for (int i = 0; i < n; i++) {
		int x = (cost[0][i] + cost[1][i]) % m;
		dp[now][x] = 1;
	}
	int next;
	for (int k = 0; k < l; k++) {
		next = 1-now;
		dp[next].assign(m, 0);
		for (int i = 0; i < m; i++)
			for (auto &v : cm) {
				int ni = (i + v.first) %  m;
				dp[next][ni] += (dp[now][i]*v.second)%M;
			}
		now = next;
	}
	return dp[now][0];
}

int main() {
	read_data();
	cout << deal() << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <cstring>
#include <stack>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <tuple>
using namespace std;

#define M (1000000007)
#define CM 100
int n, l, m;
vector<int> cost[3];
vector<int> num;
map<int, int> c2i;
vector<vector<int> > mat;

void read_data() {
	cin >> n >> l >> m;
	for (int i = 0; i < 3; i++) {
		cost[i].reserve(n);
		int ci;
		for (int j = 0; j < n; j++) {
			scanf("%d", &ci);
			cost[i].push_back(ci);
		}
	}
	num.assign(m, 0);
	for (int i = 0; i < n; i++) {
		int mx = cost[1][i] % m;
		num[mx]++;
	}
	mat.resize(m);
	for (int i = 0; i < m; i++) {
		mat[i].resize(m);
	}
	for (int k = 0; k < m; k++)
		for (int j = 0; j < m; j++)
			mat[(j-k+m)%m][j] = num[k];
}

vector<vector<int> > mul(vector<vector<int> > &a, vector<vector<int> > &b) {
	vector<vector<int> > res;
	int n = a.size();
	int t = a[0].size();
	int m = b[0].size();
	res.resize(n);
	for (int i = 0; i < n; i++)
		res[i].resize(m);
	for (int i = 0; i < n; i++)
		for (int k = 0; k < m; k++) {
			long long rx = 0;
			for (int j = 0; j < t; j++) {
				rx += (1LL * a[i][j] * b[j][k]);
				rx %= M;
			}
			res[i][k] = rx;
		}
	return res;
}

vector<vector<int> > bi_pow(vector<vector<int> > base, int e) {
	vector<vector<int> > res;
	int n = base.size();
	res.resize(n);
	for (int i = 0; i < n; i++) {
		res[i].resize(n);
		res[i][i] = 1;
	}
	while (e != 0) {
		if (e&1) res = mul(res, base);
		e = e >> 1;
		base = mul(base, base);
	}
	return res;
}

int main() {
	read_data();
	vector<vector<int> > start;
	start.resize(1);
	start[0].assign(m, 0);
	for (int i = 0; i < n; i++)
		start[0][cost[0][i]%m]++;
	mat = bi_pow(mat, l-2);
	vector<vector<int> > res = mul(start, mat);
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		int t = m - (cost[1][i] + cost[2][i]) % m;
		ans += res[0][t];
		ans %= M;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <cstring>
#include <stack>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <tuple>
using namespace std;

#define M (1000000007)
int n, l, m;
vector<int> cost[3];
vector<int> num;
vector<vector<int> > mat;

void read_data() {
	cin >> n >> l >> m;
	for (int i = 0; i < 3; i++) {
		cost[i].reserve(n);
		int ci;
		for (int j = 0; j < n; j++) {
			scanf("%d", &ci);
			cost[i].push_back(ci);
		}
	}
	num.assign(m, 0);
	for (int i = 0; i < n; i++) {
		int mx = cost[1][i] % m;
		num[mx]++;
	}
	mat.resize(m);
	for (int i = 0; i < m; i++) {
		mat[i].resize(m);
	}
	for (int k = 0; k < m; k++)
		for (int j = 0; j < m; j++)
			mat[(j-k+m)%m][j] = num[k];
}

vector<vector<int> > mul(vector<vector<int> > &a, vector<vector<int> > &b) {
	vector<vector<int> > res;
	int n = a.size();
	int t = a[0].size();
	int m = b[0].size();
	res.resize(n);
	for (int i = 0; i < n; i++)
		res[i].resize(m);
	for (int i = 0; i < n; i++)
		for (int k = 0; k < m; k++) {
			long long rx = 0;
			for (int j = 0; j < t; j++) {
				rx += (1LL * a[i][j] * b[j][k]);
				rx %= M;
			}
			res[i][k] = rx;
		}
	return res;
}

vector<vector<int> > bi_pow(vector<vector<int> > base, int e) {
	vector<vector<int> > res;
	int n = base.size();
	res.resize(n);
	for (int i = 0; i < n; i++) {
		res[i].resize(n);
		res[i][i] = 1;
	}
	while (e != 0) {
		if (e&1) res = mul(res, base);
		e = e >> 1;
		base = mul(base, base);
	}
	return res;
}

int main() {
	read_data();
	vector<vector<int> > start;
	start.resize(1);
	start[0].assign(m, 0);
	for (int i = 0; i < n; i++)
		start[0][cost[0][i]%m]++;
	mat = bi_pow(mat, l-2);
	vector<vector<int> > res = mul(start, mat);
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		int t = m - (cost[1][i] + cost[2][i]) % m;
		if (t == m) t = 0;
		ans += res[0][t];
		ans %= M;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int mod = 7 + 1e9;
const int N = 103;

int n, L, m;
int bb[1000006], cc;

struct matrix {
	int a[N];
	matrix operator * (const matrix& b) const {
		static matrix ans;
		memset(ans.a, 0, sizeof ans.a);
		for (int i = 0; i < m; ++i)
			for (int j = 0; j < m; ++j)
				ans.a[(i + j) % m] = (ans.a[(i + j) % m] + (ll)a[i] * b.a[j]) % mod;
		return ans;
	}
	matrix operator ^ (int n) const {
		static matrix ans, q;
		q = *this;
		ans.a[0] = 1;
		while (n) {
			if (n & 1) ans = ans * q;
			q = q * q;
			n >>= 1;
		}
		return ans;
	}
} a, b, c;

int main() {
	scanf("%d%d%d", &n, &L, &m);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &cc);
		++a.a[cc];
	}
	for (int i = 0; i < n; ++i) {
		scanf("%d", &cc);
		++b.a[cc];
		bb[i] = cc;
	}
	for (int i = 0; i < n; ++i) {
		scanf("%d", &cc);
		++c.a[(bb[i] + cc) % m];
	}
	b = b ^ (L - 2);
	a = a * b * c;
	cout << a.a[0] << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int mod = 7 + 1e9;
const int N = 103;

int n, L, m;
int bb[N], cc;

struct matrix {
	int a[N];
	matrix operator * (const matrix& b) const {
		static matrix ans;
		memset(ans.a, 0, sizeof ans.a);
		for (int i = 0; i < m; ++i)
			for (int j = 0; j < m; ++j)
				ans.a[(i + j) % m] = (ans.a[(i + j) % m] + (ll)a[i] * b.a[j]) % mod;
		return ans;
	}
	matrix operator ^ (int n) const {
		static matrix ans, q;
		q = *this;
		ans.a[0] = 1;
		while (n) {
			if (n & 1) ans = ans * q;
			q = q * q;
			n >>= 1;
		}
		return ans;
	}
} a, b, c;

int main() {
	cin >> n >> L >> m;
	for (int i = 0; i < n; ++i) {
		cin >> cc;
		++a.a[cc];
	}
	for (int i = 0; i < n; ++i) {
		cin >> cc;
		++b.a[cc];
		bb[i] = cc;
	}
	for (int i = 0; i < n; ++i) {
		cin >> cc;
		++c.a[(bb[i] + cc) % m];
	}
	b = b ^ (L - 2);
	a = a * b * c;
	cout << a.a[0] << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int mod = 7 + 1e9;
const int N = 103;

int n, L, m;
int bb[1000006], cc;

struct matrix {
	int a[N];
	matrix operator * (const matrix& b) const {
		static matrix ans;
		memset(ans.a, 0, sizeof ans.a);
		for (int i = 0; i < m; ++i)
			for (int j = 0; j < m; ++j)
				ans.a[(i + j) % m] = (ans.a[(i + j) % m] + (ll)a[i] * b.a[j]) % mod;
		return ans;
	}
	matrix operator ^ (int n) const {
		static matrix ans, q;
		q = *this;
		ans.a[0] = 1;
		while (n) {
			if (n & 1) ans = ans * q;
			q = q * q;
			n >>= 1;
		}
		return ans;
	}
} a, b, c;

int main() {
	cin >> n >> L >> m;
	for (int i = 0; i < n; ++i) {
		cin >> cc;
		++a.a[cc];
	}
	for (int i = 0; i < n; ++i) {
		cin >> cc;
		++b.a[cc];
		bb[i] = cc;
	}
	for (int i = 0; i < n; ++i) {
		cin >> cc;
		++c.a[(bb[i] + cc) % m];
	}
	b = b ^ (L - 2);
	a = a * b * c;
	cout << a.a[0] << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <ctime>
#include <climits>
#include <cstdlib>

const double Pi=acos(-1.0);
typedef long long LL;

#define Set(a, s) memset(a, s, sizeof (a))
#define Rd(r) freopen(r, "r", stdin)
#define Wt(w) freopen(w, "w", stdout)

using namespace std;

const LL mod=1000000007;

int N, L, M;
int ln[105], cnt[105];

LL v[105], mat[105][105];

void vmMult () {
	LL tmp[105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			tmp[i]=(tmp[i]+(mat[i][j]*v[j])%mod)%mod;
	}
	for (int i=0; i<M; i++)
		v[i]=tmp[i];
}

void matMult () {
	LL tmp[105][105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++) {
			for (int k=0; k<M; k++)
				tmp[i][j]=(tmp[i][j]+(mat[i][k]*mat[k][j])%mod)%mod;
		}
	}
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			mat[i][j]=tmp[i][j];
	}
}

void exp (int x) {
	while (x) {
		if (x&1)
			vmMult();
		matMult();
		x/=2;
	}
}

int main (int argc, char ** argv) {
	scanf("%d %d %d", &N, &L, &M);
	int x;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		v[x]++;
	}
	for (int i=0; i<N; i++) {
		scanf("%d", &ln[i]);
		cnt[ln[i]]++;
	}
	for (int i=0; i<M; i++) {
		if (cnt[i]) {
			for (int j=0; j<M; j++)
				mat[(j+i)%M][j]+=cnt[i];
		}
	}
	exp(L-2);
	LL ans=0;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		x=(x+ln[i])%M;
		ans=(ans+v[(M-x)%M])%mod;
	}
	printf("%lld", ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <ctime>
#include <climits>
#include <cstdlib>

const double Pi=acos(-1.0);
typedef long long LL;

#define Set(a, s) memset(a, s, sizeof (a))
#define Rd(r) freopen(r, "r", stdin)
#define Wt(w) freopen(w, "w", stdout)

using namespace std;

const LL mod=1000000007;

int N, L, M;
int ln[105], cnt[105];

LL v[105], mat[105][105];

void vmMult () {
	LL tmp[105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			tmp[i]=(tmp[i]+(mat[i][j]*v[j])%mod)%mod;
	}
	for (int i=0; i<M; i++)
		v[i]=tmp[i];
}

void matMult () {
	LL tmp[105][105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++) {
			for (int k=0; k<M; k++)
				tmp[i][j]=(tmp[i][j]+(mat[i][k]*mat[k][j])%mod)%mod;
		}
	}
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			mat[i][j]=tmp[i][j];
	}
}

void exp (int x) {
	while (x) {
		if (x&1)
			vmMult();
		matMult();
		x/=2;
	}
}

int main (int argc, char ** argv) {
	scanf("%d %d %d", &N, &L, &M);
	int x;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		v[x]++;
	}
	for (int i=0; i<N; i++) {
		scanf("%d", &ln[i]);
		cnt[ln[i]]++;
	}
	for (int i=0; i<M; i++) {
		if (cnt[i]) {
			for (int j=0; j<M; j++)
				mat[(j+i)%M][j]=cnt[i];
		}
	}
	exp(L-2);
	LL ans=0;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		x=(x+ln[i])%M;
		ans=(ans+v[(M-x)%M])%mod;
	}
	printf("%lld", ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <ctime>
#include <climits>
#include <cstdlib>

const double Pi=acos(-1.0);
typedef long long LL;

#define Set(a, s) memset(a, s, sizeof (a))
#define Rd(r) freopen(r, "r", stdin)
#define Wt(w) freopen(w, "w", stdout)

using namespace std;

const LL mod=1000000007;

int N, L, M;
int ln[105], cnt[105];

LL v[105], mat[105][105];

void vmMult () {
	LL tmp[105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			tmp[i]=(tmp[i]+(mat[i][j]*v[j])%mod)%mod;
	}
	for (int i=0; i<M; i++)
		v[i]=tmp[i];
}

void matMult () {
	LL tmp[105][105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++) {
			for (int k=0; k<M; k++)
				tmp[i][j]=(tmp[i][j]+(mat[i][k]*mat[k][j])%mod)%mod;
		}
	}
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			mat[i][j]=tmp[i][j];
	}
}

void exp (int x) {
	while (x) {
		if (x&1)
			vmMult();
		matMult();
		x>>=1;
	}
}

int main (int argc, char ** argv) {
	scanf("%d %d %d", &N, &L, &M);
	int x;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		v[x%M]++;
	}
	for (int i=0; i<N; i++) {
		scanf("%d", &ln[i]);
		cnt[ln[i]%M]++;
	}
	for (int i=0; i<M; i++) {
		if (cnt[i]) {
			for (int j=0; j<M; j++)
				mat[(j+i)%M][j]=cnt[i];
		}
	}
	exp(L-2);
	LL ans=0;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		ans=(ans+v[(2*M-x-ln[i])%M])%mod;
	}
	printf("%lld", ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <ctime>
#include <climits>
#include <cstdlib>

const double Pi=acos(-1.0);
typedef long long LL;

#define Set(a, s) memset(a, s, sizeof (a))
#define Rd(r) freopen(r, "r", stdin)
#define Wt(w) freopen(w, "w", stdout)

using namespace std;

const LL mod=1000000007;

int N, L, M;
LL ln[105], cnt[105];

LL v[105], mat[105][105];

void vmMult () {
	LL tmp[105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			tmp[i]=(tmp[i]+(mat[i][j]*v[j])%mod)%mod;
	}
	for (int i=0; i<M; i++)
		v[i]=tmp[i];
}

void matMult () {
	LL tmp[105][105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++) {
			for (int k=0; k<M; k++)
				tmp[i][j]=(tmp[i][j]+(mat[i][k]*mat[k][j])%mod)%mod;
		}
	}
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			mat[i][j]=tmp[i][j];
	}
}

void exp (int x) {
	while (x) {
		if (x&1)
			vmMult();
		matMult();
		x/=2;
	}
}

int main (int argc, char ** argv) {
	scanf("%d %d %d", &N, &L, &M);
	int x;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		v[x]++;
	}
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		ln[i]=x;
		cnt[x]++;
	}
	for (int i=0; i<M; i++) {
		if (cnt[i]) {
			for (int j=0; j<M; j++)
				mat[(j+i)%M][j]=cnt[i];
		}
	}
	exp(L-2);
	LL ans=0;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		x=(x+ln[i])%M;
		ans=(ans+v[M-x])%mod;
	}
	printf("%lld", ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <ctime>
#include <climits>
#include <cstdlib>

const double Pi=acos(-1.0);
typedef long long LL;

#define Set(a, s) memset(a, s, sizeof (a))
#define Rd(r) freopen(r, "r", stdin)
#define Wt(w) freopen(w, "w", stdout)

using namespace std;

const LL mod=1000000007;

int N, L, M;
int ln[105], cnt[105];

LL v[105], mat[105][105];

void vmMult () {
	LL tmp[105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			tmp[i]=(tmp[i]+(mat[i][j]*v[j])%mod)%mod;
	}
	for (int i=0; i<M; i++)
		v[i]=tmp[i];
}

void matMult () {
	LL tmp[105][105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++) {
			for (int k=0; k<M; k++)
				tmp[i][j]=(tmp[i][j]+(mat[i][k]*mat[k][j])%mod)%mod;
		}
	}
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			mat[i][j]=tmp[i][j];
	}
}

void exp (int x) {
	while (x) {
		if (x&1)
			vmMult();
		matMult();
		x>>=1;
	}
}

int main (int argc, char ** argv) {
	scanf("%d %d %d", &N, &L, &M);
	int x;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		v[x%M]++;
	}
	for (int i=0; i<N; i++) {
		scanf("%d", &ln[i]);
		cnt[ln[i]%M]++;
	}
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			mat[(j+i)%M][j]=cnt[i];
	}
	exp(L-2);
	LL ans=0;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		x=(x+ln[i])%M;
		ans=(ans+v[(M-x)%M])%mod;
	}
	printf("%lld", ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <ctime>
#include <climits>
#include <cstdlib>

const double Pi=acos(-1.0);
typedef long long LL;

#define Set(a, s) memset(a, s, sizeof (a))
#define Rd(r) freopen(r, "r", stdin)
#define Wt(w) freopen(w, "w", stdout)

using namespace std;

const int maxN=1000005;
const LL mod=1000000007;

int N, L, M;
int ln[maxN], cnt[105];

LL v[105], mat[105][105];

void vmMult () {
	LL tmp[105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			tmp[i]=(tmp[i]+(mat[i][j]*v[j])%mod)%mod;
	}
	for (int i=0; i<M; i++)
		v[i]=tmp[i];
}

void matMult () {
	LL tmp[105][105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++) {
			for (int k=0; k<M; k++)
				tmp[i][j]=(tmp[i][j]+(mat[i][k]*mat[k][j])%mod)%mod;
		}
	}
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			mat[i][j]=tmp[i][j];
	}
}

void exp (int p) {
	while (p) {
		if (p&1)
			vmMult();
		matMult();
		p>>=1;
	}
}

int main (int argc, char ** argv) {
	scanf("%d %d %d", &N, &L, &M);
	int x;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		v[x%M]++;
	}
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		ln[i]=x%M;
		cnt[ln[i]]++;
	}
	for (int i=0; i<M; i++) {
		if (cnt[i]) {
			for (int j=0; j<M; j++)
				mat[(j+i)%M][j]=cnt[i];
		}
	}
	exp(L-2);
	LL ans=0;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		x=(x+ln[i])%M;
		ans=(ans+v[(M-x)%M])%mod;
	}
	printf("%lld", ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <ctime>
#include <climits>
#include <cstdlib>

const double Pi=acos(-1.0);
typedef long long LL;

#define Set(a, s) memset(a, s, sizeof (a))
#define Rd(r) freopen(r, "r", stdin)
#define Wt(w) freopen(w, "w", stdout)

using namespace std;

const LL mod=1000000007;

int N, L, M;
int ln[105], cnt[105];

LL v[105], mat[105][105];

void vmMult () {
	LL tmp[105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			tmp[i]=(tmp[i]+(mat[i][j]*v[j])%mod)%mod;
	}
	for (int i=0; i<M; i++)
		v[i]=tmp[i];
}

void matMult () {
	LL tmp[105][105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++) {
			for (int k=0; k<M; k++)
				tmp[i][j]=(tmp[i][j]+(mat[i][k]*mat[k][j])%mod)%mod;
		}
	}
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			mat[i][j]=tmp[i][j];
	}
}

void exp (int p) {
	while (p) {
		if (p&1)
			vmMult();
		matMult();
		p>>=1;
	}
}

int main (int argc, char ** argv) {
	scanf("%d %d %d", &N, &L, &M);
	int x;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		v[x%M]++;
	}
	for (int i=0; i<N; i++) {
		scanf("%d", &ln[i]);
		cnt[ln[i]%M]++;
	}
	for (int i=0; i<M; i++) {
		if (cnt[i]) {
			for (int j=0; j<M; j++)
				mat[(j+i)%M][j]=cnt[i];
		}
	}
	exp(L-2);
	LL ans=0;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		ans=(ans+v[(2*M-x-ln[i])%M])%mod;
	}
	printf("%lld", ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <ctime>
#include <climits>
#include <cstdlib>

const double Pi=acos(-1.0);
typedef long long LL;

#define Set(a, s) memset(a, s, sizeof (a))
#define Rd(r) freopen(r, "r", stdin)
#define Wt(w) freopen(w, "w", stdout)

using namespace std;

const LL mod=1000000007;

int N, L, M;
int ln[105], cnt[105];

LL v[105], mat[105][105];

void vmMult () {
	LL tmp[105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			tmp[i]=(tmp[i]+(mat[i][j]*v[j])%mod)%mod;
	}
	for (int i=0; i<M; i++)
		v[i]=tmp[i];
}

void matMult () {
	LL tmp[105][105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++) {
			for (int k=0; k<M; k++)
				tmp[i][j]=(tmp[i][j]+(mat[i][k]*mat[k][j])%mod)%mod;
		}
	}
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			mat[i][j]=tmp[i][j];
	}
}

void exp (int x) {
	while (x) {
		if (x&1)
			vmMult();
		matMult();
		x>>=1;
	}
}

int main (int argc, char ** argv) {
	scanf("%d %d %d", &N, &L, &M);
	int x;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		v[x%M]++;
	}
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		ln[i]=x%M;
		cnt[ln[i]]++;
	}
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			mat[(j+i)%M][j]+=cnt[i];
	}
	exp(L-2);
	LL ans=0;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		x=(x+ln[i])%M;
		ans=(ans+v[(M-x)%M])%mod;
	}
	printf("%lld", ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <ctime>
#include <climits>
#include <cstdlib>

const double Pi=acos(-1.0);
typedef long long LL;

#define Set(a, s) memset(a, s, sizeof (a))
#define Rd(r) freopen(r, "r", stdin)
#define Wt(w) freopen(w, "w", stdout)

using namespace std;

const LL mod=1000000007;

int N, L, M;
int ln[105], cnt[105];

LL v[105], mat[105][105];

void vmMult () {
	LL tmp[105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			tmp[i]=(tmp[i]+(mat[i][j]*v[j])%mod)%mod;
	}
	for (int i=0; i<M; i++)
		v[i]=tmp[i];
}

void matMult () {
	LL tmp[105][105]={0};
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++) {
			for (int k=0; k<M; k++)
				tmp[i][j]=(tmp[i][j]+(mat[i][k]*mat[k][j])%mod)%mod;
		}
	}
	for (int i=0; i<M; i++) {
		for (int j=0; j<M; j++)
			mat[i][j]=tmp[i][j];
	}
}

void exp (int x) {
	while (x) {
		if (x&1)
			vmMult();
		matMult();
		x/=2;
	}
}

int main (int argc, char ** argv) {
	scanf("%d %d %d", &N, &L, &M);
	int x;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		v[x%M]++;
	}
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		ln[i]=x%M;
		cnt[ln[i]]++;
	}
	for (int i=0; i<M; i++) {
		if (cnt[i]) {
			for (int j=0; j<M; j++)
				mat[(j+i)%M][j]=cnt[i];
		}
	}
	exp(L-2);
	LL ans=0;
	for (int i=0; i<N; i++) {
		scanf("%d", &x);
		x=(x+ln[i])%M;
		ans=(ans+v[(M-x)%M])%mod;
	}
	printf("%lld", ans);
	return 0;
}


#include <bits/stdc++.h>
#define dbg(x) std::cerr << #x << " = " << x << "\n"
using namespace std;
typedef long long ll;
typedef unsigned long long INT;
const ll mo = (ll)(1e9 + 7);

int rem[1000000 + 5];
struct mat {
	int r, c; ll a[110][110];
	mat() {memset(a, 0, sizeof(a));}
	mat operator * (const mat& b) const {
		mat ans; ans.r = r; ans.c = b.c;
		for(int i = 1; i <= ans.r; i++)
			for(int j = 1; j <= ans.c; j++)
				for(int k = 1; k <= c; k++)
					ans.a[i][j] = (ans.a[i][j] + a[i][k] % mo * b.a[k][j] % mo) % mo;
		return ans;
	}
};
mat qpow(mat x, ll k){
	mat ans = x; --k;
	while(k) {
		if(k & 1) ans = ans * x;
		x = x * x;
		k >>= 1;
	}
	return ans;
}
int n, l, m;
int po[3][110];
int main() {
	scanf("%d%d%d", &n, &l, &m);

	for(int i = 1; i <= n; i++) {
		int x; scanf("%d", &x);
		po[0][x]++;
	}
	for(int i = 1; i <= n; i++) {
		int x; scanf("%d", &x);
		rem[i] = x;
		po[1][x]++;
	}
	for(int i = 1; i <= n; i++) {
		int x; scanf("%d", &x);
		x = (x + rem[i]) % m;
		po[2][x]++;
	}

	mat st; st.r = m; st.c = 1;
	st.a[1][1] = 1;
	mat bas; bas.r = bas.c = m;
	for(int i = 0; i < m; i++) {
		for(int j = 0; j < m; j++) {
			bas.a[i + 1][(i - j + m) % m + 1] = po[0][j];
		}
	}

	st = bas * st;
	//for(int i = 1; i <= m; i++) cout << st.a[i][1] << "!!\n";
	for(int i = 0; i < m; i++)
		for(int j = 0; j < m; j++)
			bas.a[i + 1][j + 1] = 0;

	for(int i = 0; i < m; i++)
		for(int j = 0; j < m; j++) {
			bas.a[i + 1][(i - j + m) % m + 1] = po[1][j];
		}

	if(l > 2)
		st = qpow(bas, l - 2) * st;

	for(int i = 0; i < m; i++)
		for(int j = 0; j < m; j++)
			bas.a[i + 1][j + 1] = 0;

	for(int i = 0; i < m; i++)
		for(int j = 0; j < m; j++) {
			bas.a[i + 1][(i - j + m) % m + 1] = po[2][j];
		}
	st = bas * st;
	cout << st.a[1][1] << endl;
	return 0;
}


#include <bits/stdc++.h>
#define For(i,a,b) for ( int i=(a);i<=(b);i++ )
#define Dow(i,b,a) for ( int i=(b);i>=(a);i-- )
#define GO(i,x) for ( int i=head[x];i;i=e[i].nex )
#define mem(x,s) memset(x,s,sizeof(x))
#define cpy(x,s) memcpy(x,s,sizeof(x))
#define YES return puts("YES"),0
#define NO return puts("NO"),0
#define GG return puts("-1"),0
#define pb push_back
#define int long long
using namespace std;

struct IO
{
	#define MAXSIZE (1 << 20)
	#define isdigit(x) (x >= '0' && x <= '9')
  	char buf[MAXSIZE],*p1,*p2;
  	char pbuf[MAXSIZE],*pp;
  	IO():p1(buf),p2(buf),pp(pbuf){}
  	inline char gc() {
    	return getchar();
    	if (p1==p2) p2=(p1=buf)+fread(buf,1,MAXSIZE,stdin);
    	return p1==p2?' ':*p1++;
  	}
	inline bool blank(char ch) {return ch==' '||ch =='\n'||ch == '\r'||ch == '\t';}
  	template <class T>
  	inline void read(T &x)
	{
	    register double tmp=1;register bool sign=0; x=0;
	    register char ch=gc();
	    for (;!isdigit(ch);ch=gc()) if(ch=='-') sign=1;
	    for (;isdigit(ch);ch=gc()) x=x*10+(ch-'0');
	    if (ch=='.') for (ch=gc();isdigit(ch);ch=gc()) tmp/=10.0,x+=tmp*(ch-'0');
	    if (sign) x=-x;
  	}
  	inline void read(char *s)
	{
    	register char ch=gc();
		for (;blank(ch);ch=gc());
		for (;!blank(ch);ch=gc()) *s++=ch;
    	*s=0;
  	}
  	inline void read(char &c) {for(c=gc();blank(c);c=gc());}
  	template<class t> inline void write(t x){
		if(x<0) putchar('-'),write(-x);
		else{if(x>9) write(x/10);putchar('0'+x%10);}
	}
} io;

const int mod=1e9+7;
const int mo=998244353;
const int N=1e6+5;

int n,L,m,a[N];

inline void Add(int &x,int y)
{
	x+=y;
	if(x>=mod) x%=mod;
}

struct Node
{
	int a[105];
	Node(){mem(a,0);}
	inline Node friend operator * (Node &s,Node &t)
	{
		Node c;
		For(i,0,m-1) For(j,0,m-1) Add(c.a[(i+j)%m],s.a[i]*t.a[j]%mod);
		return c;
	}
};
Node A,B,C;

inline Node ksm(Node a,int y)
{
	Node ans;
	ans=a;
	y--;
	while(y)
	{
		if(y&1) ans=ans*a;
		a=a*a;
		y>>=1ll;
	}
	return ans;
}

signed main()
{
	io.read(n),io.read(L),io.read(m);
	For(i,1,n)
	{
		int x; io.read(x);
		A.a[x%m]++;
	}
	For(i,1,n)
	{
		int x; io.read(x);
		a[i]=x;
		B.a[x%m]++;
	}
	For(i,1,n)
	{
		int x; io.read(x);
		C.a[(x+a[i])%m]++;
	}
	Node ans;
	if(L>2)
	{
		ans=ksm(B,L-2);
		ans=ans*A;
		ans=ans*C;
	}
	else ans=A*C;
	int Ans=0;
	For(i,0,100) if(!(i%m))
	Add(Ans,ans.a[i]);
	io.write(Ans);
	return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define LL long long
#define M 1000010
#define N 100

using namespace std;

struct matrix
{
	LL a[N][N];

	void init(){memset(a,0,sizeof(a));}

	friend matrix operator *(matrix x,matrix y)
    {
        matrix ans; ans.init();
        for(int i=0;i<N;i++)
            for(int j=0;j<N;j++)
            {
                for(int k=0;k<N;k++)
                    ans.a[i][j]+=(x.a[i][k]*y.a[k][j])%mod;
                ans.a[i][j]%=mod;
            }
        return ans;
    }

    friend matrix operator ^(matrix x,LL y)
    {
        matrix ans;
        if (y==0)
        {
            memset(ans.a,0,sizeof(ans.a));
            for(int i=0;i<N;i++) ans.a[i][i]=1;
            return ans;
        } else while ((y&1)==0) y>>=1,x=x*x;
        ans=x; y>>=1;
        for(;y!=0;y>>=1)
        {
            x=x*x; if ((y&1)!=0) ans=ans*x;
        }
        return ans;
    }
} x;

int n,m,Mod,a[M];

int main()
{
    x.init();
    matrix h,t;						//head和tail，表示首尾
    h.init(); t.init();
    scanf("%d%d%d",&n,&m,&Mod);
    for(int i=1;i<=n;i++)
    {
        int v; scanf("%d",&v);
        h.a[0][v%Mod]++;					//源点连出的边，直接从0连到相应的费用
    }
    for(int i=1;i<=n;i++)
    {
        int v; scanf("%d",&v); a[i]=v;
        for(int j=0;j<Mod;j++)						//中间点，可以从任意费用转移
            x.a[j][(j+v)%Mod]++;
    }
    matrix ans=h*(x^(m-2));						//注意少弄一层，最后一层和到汇点的合并
    for(int i=1;i<=n;i++)
    {
        int v; scanf("%d",&v);
        t.a[(Mod-(v+a[i])%Mod)%Mod][0]++;				//进行合并，构造新矩阵
    }
    ans=ans*t;										//右乘求出结果
    printf("%I64d\n",ans.a[0][0]);
}


#include<bits/stdc++.h>
#define rg register
#define i60 long long
#define int long long
#define fp( i , x , y ) for( rg int i=(x); i<=(y); ++i )
#define fq( i , x , y ) for( rg int i=(y); i>=(x); --i )
using namespace std ;
const int N = 105 ;
const i60 hgs = 1e9+7 ;
int n , l , m , A[N*10000] ;
struct Matrix {
  int a[N][N] ;
  void clean( ) { memset( a , 0 , sizeof(a) ) ; }
  friend Matrix operator *  ( Matrix A , Matrix B ) {
     Matrix C ; C.clean( ) ;
     fp( i , 0 , m-1 ) fp( j , 0 , m-1 ) fp( k , 0 , m-1 )
       C.a[i][j] += ( A.a[i][k] * (i60)B.a[k][j] % hgs ) , C.a[i][j] %= hgs ;
     return C ;
  } // f[j] += f[i] * g[i][j]
  Matrix qpow( Matrix A , int B ) {
    Matrix C ; C.clean( ) ;
    fp( i , 0 , m-1 ) C.a[i][i] = 1 ;
    for( ; B ; B >>= 1 ) {
       if( B & 1 ) C = C * A ;
       A = A * A  ;
	} return C ;
  }
} S , g ;
signed main( ) {
  int x ;
  scanf( "%lld %lld %lld" , &n , &l , &m ) ;
  fp( i , 1 , n )
    scanf( "%lld" , &x ) , S.a[0][x%m] ++ ;
  fp( i , 1 , n ) {
    scanf( "%lld" , &A[i] ) ; A[i] %= m ;
    fp( j , 0 , m-1 )
       g.a[j][(j+A[i])%m] ++ ;
  }
  S = S * g.qpow ( g , l-2 ) ;
  int ans = 0 ;
  fp( i , 1 , n ) {
     scanf( "%lld" , &x ) ; x %= m ;
	 ans = ( ans + S.a[0][(2*m-x-A[i])%m] ) % hgs ;
  }
  printf( "%lld\n" , ans ) ;
  return 0 ;
}


#include<bits/stdc++.h>
#define rg register
#define i60 long long
#define fp( i , x , y ) for( rg int i=(x); i<=(y); ++i )
#define fq( i , x , y ) for( rg int i=(y); i>=(x); --i )
using namespace std ;
const int N = 105 ;
const i60 hgs = 1e9+7 ;
int n , l , m , A[N] , ae[N] ;
struct Matrix {
  int a[N][N] ;
  void clean( ) { memset( a , 0 , sizeof(a) ) ; }
  friend Matrix operator *  ( Matrix A , Matrix B ) {
     Matrix C ; C.clean( ) ;
     fp( k , 0 , m-1 ) fp( i , 0 , m-1 ) fp( j , 0 , m-1 )
       C.a[i][j] += ( A.a[i][k] * (i60)B.a[k][j] % hgs ) , C.a[i][j] %= hgs ;
     return C ;
  } // f[j] += f[i] * g[i][j]
  Matrix qpow( Matrix A , int B ) {
    Matrix C ; C.clean( ) ;
    fp( i , 0 , m-1 ) C.a[i][i] = 1 ;
    for( ; B ; B >>= 1 ) {
       if( B & 1 ) C = C * A ;
       A = A * A  ;
	} return C ;
  }
} S , g ;
signed main( ) {
  int x ;
  scanf( "%d %d %d" , &n , &l , &m ) ;
  fp( i , 1 , n )
    scanf( "%d" , &x ) , S.a[0][x%m] ++ ;
  fp( i , 1 , n ) {
    scanf( "%d" , &A[i] ) ;
    fp( j , 0 , m-1 )
       g.a[j][(j+A[i])%m] ++ ;
  }
  S = S * g.qpow ( g , l-2 ) ;
  int ans = 0 ;
  fp( i , 1 , n ) {
     scanf( "%d" , &x ) ; x %= m ;
	 ans = ( ans + (i60)S.a[0][(2*m-x-A[i])%m] % hgs ) % hgs ;
  }
  printf( "%d\n" , ans ) ;
  return 0 ;
}


#include<bits/stdc++.h>
#define rg register
#define i60 long long
#define int long long
#define fp( i , x , y ) for( rg int i=(x); i<=(y); ++i )
#define fq( i , x , y ) for( rg int i=(y); i>=(x); --i )
using namespace std ;
const int N = 105 ;
const i60 hgs = 1e9+7 ;
int n , l , m , A[N] , ae[N] ;
struct Matrix {
  int a[N][N] ;
  void clean( ) { memset( a , 0 , sizeof(a) ) ; }
  friend Matrix operator *  ( Matrix A , Matrix B ) {
     Matrix C ; C.clean( ) ;
     fp( k , 0 , m-1 ) fp( i , 0 , m-1 ) fp( j , 0 , m-1 )
       C.a[i][j] += ( A.a[i][k] * (i60)B.a[k][j] % hgs ) , C.a[i][j] %= hgs ;
     return C ;
  } // f[j] += f[i] * g[i][j]
  Matrix qpow( Matrix A , int B ) {
    Matrix C ; C.clean( ) ;
    fp( i , 0 , m-1 ) C.a[i][i] = 1 ;
    for( ; B ; B >>= 1 ) {
       if( B & 1 ) C = C * A ;
       A = A * A  ;
	} return C ;
  }
} S , g ;
signed main( ) {
  int x ;
  scanf( "%lld %lld %lld" , &n , &l , &m ) ;
  fp( i , 1 , n )
    scanf( "%lld" , &x ) , S.a[0][x%m] ++ ;
  fp( i , 1 , n ) {
    scanf( "%lld" , &A[i] ) ;
    fp( j , 0 , m-1 )
       g.a[j][(j+A[i])%m] ++ ;
  }
  S = S * g.qpow ( g , l-2 ) ;
  int ans = 0 ;
  fp( i , 1 , n ) {
     scanf( "%lld" , &x ) ; x %= m ;
	 ans = ( ans + (i60)S.a[0][(2*m-x-A[i])%m] % hgs ) % hgs ;
  }
  printf( "%lld\n" , ans ) ;
  return 0 ;
}


#include<bits/stdc++.h>
#define rg register
#define i60 long long
#define int long long
#define fp( i , x , y ) for( rg int i=(x); i<=(y); ++i )
#define fq( i , x , y ) for( rg int i=(y); i>=(x); --i )
using namespace std ;
const int N = 105 ;
const i60 hgs = 1e9+7 ;
int n , l , m , A[N] , ae[N] ;
struct Matrix {
  int a[N][N] ;
  void clean( ) { memset( a , 0 , sizeof(a) ) ; }
  friend Matrix operator *  ( Matrix A , Matrix B ) {
     Matrix C ; C.clean( ) ;
     fp( k , 0 , m-1 ) fp( i , 0 , m-1 ) fp( j , 0 , m-1 )
       C.a[i][j] += ( A.a[i][k] * (i60)B.a[k][j] % hgs ) , C.a[i][j] %= hgs ;
     return C ;
  } // f[j] += f[i] * g[i][j]
  Matrix qpow( Matrix A , int B ) {
    Matrix C ; C.clean( ) ;
    fp( i , 0 , m-1 ) C.a[i][i] = 1 ;
    for( ; B ; B >>= 1 ) {
       if( B & 1 ) C = C * A ;
       A = A * A  ;
	} return C ;
  }
} S , g ;
signed main( ) {
  int x ;
  scanf( "%lld %lld %lld" , &n , &l , &m ) ;
  fp( i , 1 , n )
    scanf( "%lld" , &x ) , S.a[0][x%m] ++ ;
  fp( i , 1 , n ) {
    scanf( "%lld" , &A[i] ) ; A[i] %= m ;
    fp( j , 0 , m-1 )
       g.a[j][(j+A[i])%m] ++ ;
  }
  S = S * g.qpow ( g , l-2 ) ;
  int ans = 0 ;
  fp( i , 1 , n ) {
     scanf( "%lld" , &x ) ; x %= m ;
	 ans = ( ans + (i60)S.a[0][(2*m-x-A[i])%m] ) % hgs ;
  }
  printf( "%lld\n" , ans ) ;
  return 0 ;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef double DB;

#define pb push_back
#define mset(a, b) memset(a, b, sizeof a)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1 << (x))
#define bitl(x) (1LL << (x))
#define sqr(x) ((x) * (x))
#define sz(x) ((int)(x.size()))
#define cnti(x) (__builtin_popcount(x))
#define cntl(x) (__builtin_popcountll(x))
#define clzi(x) (__builtin_clz(x))
#define clzl(x) (__builtin_clzll(x))
#define ctzi(x) (__builtin_ctz(x))
#define ctzl(x) (__builtin_ctzll(x))

#define X first
#define Y second

#define Error(x) cout << #x << " = " << x << endl

template <typename T, typename U>
inline void chkmax(T& x, U y) {
	if (x < y) x = y;
}

template <typename T, typename U>
inline void chkmin(T& x, U y) {
	if (y < x) x = y;
}

const int MAXN = 1e6+5;
const int MOD = 1e9+7;

int _b[111][111], M;
void matbox(int a[111][111], int b[111][111]) {

	int c[111][111] = {0};
	for (int i = 0; i < M; i++)
		for (int j = 0; j < M; j++)
			for (int k = 0; k < M; k++) c[i][j] = (c[i][j] + 1LL * a[i][k] * b[k][j]) % MOD;
	for (int i = 0; i < M; i++)
		for (int j = 0; j < M; j++) a[i][j] = c[i][j];
}

void matpow(int n, int a[111][111]) {
	if (!n) {

		for (int i = 0; i < M; i++)
			for (int j = 0; j < M; j++) a[i][j] = int(i == j);
		return;
	}

	matpow(n / 2, a);
	matbox(a, a);
	if (n & 1) matbox(a, _b);
}

int a[MAXN], f[MAXN], s[MAXN], c[MAXN], d[MAXN], cnt[MAXN];
int N, L, dp[111][111];
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d%d%d", &N, &L, &M);
	for (int i = 0; i < N; i++) scanf("%d", f + i);
	for (int i = 0; i < N; i++) scanf("%d", a + i);
	for (int i = 0; i < N; i++) scanf("%d", s + i);
	for (int i = 0; i < N; i++) cnt[a[i] % M]++;
	for (int i = 0; i < M; i++)
		for (int j = 0; j < M; j++) _b[i][j] = cnt[(i - j + M) % M];
	int A[111][111];
	matpow(L - 2, A);

	for (int i = 0; i < N; i++) c[f[i] % M]++;
	for (int i = 0; i < M; i++)
		for (int j = 0; j < M; j++) {
			d[i] = (d[i] + 1LL * c[j] * A[i][j]) % MOD;
		}
	int ans = 0;
	for (int i = 0; i < N; i++) ans = (ans + d[(M + M - s[i] - a[i]) % M]) % MOD;
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef double DB;

#define pb push_back
#define mset(a, b) memset(a, b, sizeof a)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1 << (x))
#define bitl(x) (1LL << (x))
#define sqr(x) ((x) * (x))
#define sz(x) ((int)(x.size()))
#define cnti(x) (__builtin_popcount(x))
#define cntl(x) (__builtin_popcountll(x))
#define clzi(x) (__builtin_clz(x))
#define clzl(x) (__builtin_clzll(x))
#define ctzi(x) (__builtin_ctz(x))
#define ctzl(x) (__builtin_ctzll(x))

#define X first
#define Y second

#define Error(x) cout << #x << " = " << x << endl

template <typename T, typename U>
inline void chkmax(T& x, U y) {
	if (x < y) x = y;
}

template <typename T, typename U>
inline void chkmin(T& x, U y) {
	if (y < x) x = y;
}

const int MAXN = 1e6+5;
const int MOD = 1e9+7;

int _b[111][111], M;
void matbox(int a[111][111], int b[111][111]) {

	int c[111][111] = {0};
	for (int i = 0; i < M; i++)
		for (int j = 0; j < M; j++)
			for (int k = 0; k < M; k++) c[i][j] = (c[i][j] + 1LL * a[i][k] * b[k][j]) % MOD;
	for (int i = 0; i < M; i++)
		for (int j = 0; j < M; j++) a[i][j] = c[i][j];
}

void matpow(int n, int a[111][111]) {
	if (!n) {

		for (int i = 0; i < M; i++)
			for (int j = 0; j < M; j++) a[i][j] = int(i == j);
		return;
	}

	matpow(n / 2, a);
	matbox(a, a);
	if (n & 1) matbox(a, _b);
}

int a[MAXN], f[MAXN], s[MAXN], c[MAXN], d[MAXN], cnt[MAXN];
int N, L, dp[111][111];
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d%d%d", &N, &L, &M);
	for (int i = 0; i < N; i++) scanf("%d", f + i);
	for (int i = 0; i < N; i++) scanf("%d", a + i);
	for (int i = 0; i < N; i++) scanf("%d", s + i);
	for (int i = 0; i < N; i++) cnt[a[i] % M]++;
	for (int i = 0; i < M; i++)
		for (int j = 0; j < M; j++) _b[i][j] = cnt[(i - j + M) % M];
	int A[111][111];
	matpow(L - 2, A);

	for (int i = 0; i < N; i++) c[f[i] % M]++;
	for (int i = 0; i < M; i++)
		for (int j = 0; j < M; j++) {
			d[i] = (d[i] + 1LL * c[j] * A[i][j]) % MOD;
		}
	for (int i = 0; i < N; i++) {

		for (int j = 0; j < M; j++) dp[i][(j + a[i]) % M] = d[j];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) ans = (ans + dp[i][(M - s[i]) % M]) % MOD;
	printf("%d\n", ans);
	return 0;
}


/*****************************************************
   *Author*         :  Jstyle
   *Email*          :  1281065596@qq.com
   *Created Time*   :  2017-09-06 10:24
*****************************************************/

#pragma GCC diagnostic error "-std=c++11"
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define FIN freopen("in.txt","r",stdin)
#define IO ios_base::sync_with_stdio(0),cin.tie(0)
#define pb push_back
typedef long long LL;
typedef pair<int, LL> PIR;

const int MAXN = 1e6+5;
const LL mod = 1e9+7;

int n, l;
LL x, m, a[MAXN];

struct Mat {
    LL cnt[105];
} mat, mat1, mat2, mat3;

Mat cal (Mat mt1, Mat mt2) {
    Mat ans;
    mem(ans.cnt, 0);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < m; ++j) {
            ans.cnt[(i+j)%m] += mt1.cnt[i]*mt2.cnt[j];
            ans.cnt[(i+j)%m] %= mod;
        }
    }
    return ans;
}

Mat qpow (Mat mt, int t) {
    Mat ans = mt;
    while (t) {
        if (t&1)  ans = cal(ans, mt);
        t >>= 1;
        mt = cal(mt, mt);
    }
    return ans;
}
int main ()
{IO;
    //FIN;
    cin >> n >> l >> m;
    mem(a, 0); mem(mat.cnt, 0); mem(mat1.cnt, 0); mem(mat2.cnt, 0); mem(mat3.cnt, 0);
    for (int i = 1; i <= n; ++i) { cin >> x; mat1.cnt[x%m]++; }
    for (int i = 1; i <= n; ++i) { cin >> x; mat2.cnt[x%m]++; a[i] = x; }
    for (int i = 1; i <= n; ++i) { cin >> x; mat3.cnt[(x+a[i])%m]++; }
    if (l <= 2) mat = cal(mat1, mat2);
    else {
        mat = qpow(mat2, l-3);
        mat = cal(mat, mat1);
        mat = cal(mat, mat3);
    }
    LL ans = 0;
    for (int i = 0; i <= 100; ++i) {
        if (i%m == 0) {
            ans += mat.cnt[i];
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}


/*****************************************************
   *Author*         :  Jstyle
   *Email*          :  1281065596@qq.com
   *Created Time*   :  2017-09-06 10:24
*****************************************************/

#pragma GCC diagnostic error "-std=c++11"
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define FIN freopen("in.txt","r",stdin)
#define IO ios_base::sync_with_stdio(0),cin.tie(0)
#define pb push_back
typedef long long LL;
typedef pair<int, LL> PIR;

const int MAXN = 1e6+5;
const LL mod = 1e9+7;

int n, l;
LL x, m, a[MAXN];

struct Mat {
    LL cnt[105];
} mat, mat1, mat2, mat3;

Mat cal (Mat mt1, Mat mt2) {
    Mat ans;
    mem(ans.cnt, 0);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < m; ++j) {
            ans.cnt[(i+j)%m] += mt1.cnt[i]*mt2.cnt[j];
            ans.cnt[(i+j)%m] %= mod;
        }
    }
    return ans;
}

Mat qpow (Mat mt, int t) {
    Mat ans = mt;
    while (t) {
        if (t&1)  ans = cal(ans, mt);
        t >>= 1;
        mt = cal(mt, mt);
    }
    return ans;
}
int main ()
{IO;
    //FIN;
    cin >> n >> l >> m;
    mem(mat.cnt, 0); mem(mat1.cnt, 0); mem(mat2.cnt, 0); mem(mat3.cnt, 0);
    for (int i = 1; i <= n; ++i) { cin >> x; mat1.cnt[x%m]++; }
    for (int i = 1; i <= n; ++i) { cin >> x; mat2.cnt[x%m]++; a[i] = x; }
    for (int i = 1; i <= n; ++i) { cin >> x; mat3.cnt[(x+a[i])%m]++; }
    if (l == 2) mat = cal(mat1, mat2);
    else {
        mat = qpow(mat2, l-3);
        mat = cal(mat, mat1);
        mat = cal(mat, mat3);
    }
    LL ans = 0;
    for (int i = 0; i <= 100; ++i) {
        if (i%m == 0) {
            ans += mat.cnt[i];
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}


/*****************************************************
   *Author*         :  Jstyle
   *Email*          :  1281065596@qq.com
   *Created Time*   :  2017-09-06 10:24
*****************************************************/

#pragma GCC diagnostic error "-std=c++11"
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define FIN freopen("in.txt","r",stdin)
#define IO ios_base::sync_with_stdio(0),cin.tie(0)
#define pb push_back
typedef long long LL;
typedef pair<int, LL> PIR;

const int MAXN = 1e6+5;
const LL mod = 1e9+7;

int n, l;
LL x, m, a[MAXN];

struct Mat {
    LL cnt[105];
} mat, mat1, mat2, mat3;

Mat cal (Mat mt1, Mat mt2) {
    Mat ans;
    mem(ans.cnt, 0);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < m; ++j) {
            ans.cnt[(i+j)%m] += mt1.cnt[i]*mt2.cnt[j];
            ans.cnt[(i+j)%m] %= mod;
        }
    }
    return ans;
}

Mat qpow (Mat mt, int t) {
    Mat ans = mt;
    t--;
    while (t) {
        if (t&1)  ans = cal(ans, mt);
        t >>= 1;
        mt = cal(mt, mt);
    }
    return ans;
}
int main ()
{IO;
    //FIN;
    cin >> n >> l >> m;
    for (int i = 1; i <= n; ++i) { cin >> x; mat1.cnt[x%m]++; }
    for (int i = 1; i <= n; ++i) { cin >> x; mat2.cnt[x%m]++; a[i] = x; }
    for (int i = 1; i <= n; ++i) { cin >> x; mat3.cnt[(x+a[i])%m]++; }
    if (l == 2) mat = cal(mat1, mat2);
    else {
        mat = qpow(mat2, l-2);
        mat = cal(mat, mat1);
        mat = cal(mat, mat3);
    }
    LL ans = 0;
    for (int i = 0; i <= 100; ++i) {
        if (i%m == 0) {
            ans += mat.cnt[i];
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}


/*****************************************************
   *Author*         :  Jstyle
   *Email*          :  1281065596@qq.com
   *Created Time*   :  2017-09-06 10:24
*****************************************************/

#pragma GCC diagnostic error "-std=c++11"
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define FIN freopen("in.txt","r",stdin)
#define IO ios_base::sync_with_stdio(0),cin.tie(0)
#define pb push_back
typedef long long LL;
typedef pair<int, LL> PIR;

const int MAXN = 1e6+5;
const LL mod = 1e9+7;

int n, l, x, m, a[MAXN];

struct Mat {
    LL cnt[105];
} mat, mat1, mat2, mat3;

Mat cal (Mat mt1, Mat mt2) {
    Mat ans;
    mem(ans.cnt, 0);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < m; ++j) {
            ans.cnt[(i+j)%m] += mt1.cnt[i]*mt2.cnt[j];
            ans.cnt[(i+j)%m] %= mod;
        }
    }
    return ans;
}

Mat qpow (Mat mt, int t) {
    Mat ans = mt;
    while (t) {
        if (t&1)  ans = cal(ans, mt);
        t >>= 1;
        mt = cal(mt, mt);
    }
    return ans;
}
int main ()
{IO;
    //FIN;
    cin >> n >> l >> m;
    mem(mat.cnt, 0); mem(mat1.cnt, 0); mem(mat2.cnt, 0); mem(mat3.cnt, 0);
    for (int i = 1; i <= n; ++i) { cin >> x; mat1.cnt[x%m]++; }
    for (int i = 1; i <= n; ++i) { cin >> x; mat2.cnt[x%m]++; a[i] = x; }
    for (int i = 1; i <= n; ++i) { cin >> x; mat3.cnt[(x+a[i])%m]++; }
    if (l == 2) mat = cal(mat1, mat2);
    else {
        mat = qpow(mat2, l-3);
        mat = cal(mat, mat1);
        mat = cal(mat, mat3);
    }
    LL ans = 0;
    for (int i = 0; i <= 100; ++i) {
        if (i%m == 0) {
            ans += mat.cnt[i];
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}


/*****************************************************
   *Author*         :  Jstyle
   *Email*          :  1281065596@qq.com
   *Created Time*   :  2017-09-06 10:24
*****************************************************/

#pragma GCC diagnostic error "-std=c++11"
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define FIN freopen("in.txt","r",stdin)
#define IO ios_base::sync_with_stdio(0),cin.tie(0)
#define pb push_back
typedef long long LL;
typedef pair<int, LL> PIR;

const int MAXN = 1e6+5;
const LL mod = 1e9+7;

int n, l;
LL x, m, a[MAXN];

struct Mat {
    LL cnt[105];
} mat, mat1, mat2, mat3;

Mat cal (Mat mt1, Mat mt2) {
    Mat ans;
    mem(ans.cnt, 0);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < m; ++j) {
            ans.cnt[(i+j)%m] = mt1.cnt[i]*mt2.cnt[j];
            ans.cnt[(i+j)%m] %= mod;
        }
    }
    return ans;
}

Mat qpow (Mat mt, int n) {
    Mat ans;
    mem(ans.cnt, 1);
    while (n) {
        if (n&1)  ans = cal(ans, mt);
        n >>= 1;
        mt = cal(mt, mt);
    }
    return ans;
}
int main ()
{IO;
    //FIN;
    cin >> n >> l >> m;
    for (int i = 1; i <= n; ++i) { cin >> x; mat1.cnt[x%m]++; }
    for (int i = 1; i <= n; ++i) { cin >> x; mat2.cnt[x%m]++; a[i] = x; }
    for (int i = 1; i <= n; ++i) { cin >> x; mat3.cnt[(x+a[i])%m]++; }
    if (l == 2) mat = cal(mat1, mat2);
    else {
        mat = qpow(mat2, l-2);
        mat = cal(mat, mat1);
        mat = cal(mat, mat3);
    }
    LL ans = 0;
    for (int i = 0; i <= 100; ++i) {
        if (i%m == 0) {
            ans += mat.cnt[i];
            ans %= mod;
        }
    }
    for (int i = 0; i <= 100; ++i) cout << mat.cnt[i] << " ";
    cout << endl;
    cout << ans << endl;
    return 0;
}