Problem: Due to the recent popularity of the Deep learning new countries are starting to look like Neural Networks. That is, the countries are being built deep with many layers, each layer possibly having many cities. They also have one entry, and one exit point.

There are exactly L layers, each having N cities. Let us look at the two adjacent layers L1 and L2. Each city from the layer L1 is connected to each city from the layer L2 with the traveling cost cij for <image>, and each pair of adjacent layers has the same cost in between their cities as any other pair (they just stacked the same layers, as usual). Also, the traveling costs to each city from the layer L2 are same for all cities in the L1, that is cij is the same for <image>, and fixed j.

Doctor G. needs to speed up his computations for this country so he asks you to find the number of paths he can take from entry to exit point such that his traveling cost is divisible by given number M.

Input

The first line of input contains N (1 ≤ N ≤ 106), L (2 ≤ L ≤ 105) and M (2 ≤ M ≤ 100), the number of cities in each layer, the number of layers and the number that travelling cost should be divisible by, respectively.

Second, third and fourth line contain N integers each denoting costs 0 ≤ cost ≤ M from entry point to the first layer, costs between adjacent layers as described above, and costs from the last layer to the exit point.

Output

Output a single integer, the number of paths Doctor G. can take which have total cost divisible by M, modulo 109 + 7.

Example

Input

2 3 13
4 6
2 1
3 4


Output

2

Note

<image>

This is a country with 3 layers, each layer having 2 cities. Paths <image>, and <image> are the only paths having total cost divisible by 13. Notice that input edges for layer cities have the same cost, and that they are same for all layers.

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {

        new Main().go();
    }

    PrintWriter out;
    Reader in;
    BufferedReader br;

    Main() throws IOException {

        try {

            //br = new BufferedReader( new FileReader("input.txt") );
            in = new Reader("input.txt");
            out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );
        }
        catch (Exception e) {

            //br = new BufferedReader( new InputStreamReader( System.in ) );
            in = new Reader();
            out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
        }
    }

    void go() throws IOException {

        int t = 1;
        int cs = 1;

        while (t > 0) {
            solve();
            //out.println();
            cs++;
            t--;
        }

        out.flush();
        out.close();
    }



    int inf = 2000000000;
    int mod = 1000000007;
    double eps = 0.00000001;

    int n;
    int m;

    //ArrayList<Integer>[] g = new ArrayList[200000];

    void solve() throws IOException {

        int n = in.nextInt();
        int l = in.nextInt();
        int m = in.nextInt();

        int[][] a = new int[m][m];
        int[][] b = new int[m][m];
        int[] c = new int[m];
        int[][] d = new int[m][m];
        int[] a1 = new int[n];
        int[] a2 = new int[n];

        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            b[0][x%m]++;
        }

        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            c[x%m]++;
            a1[i] = x;
        }

        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            d[0][x%m]++;
            a2[i] = x;
        }

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < m; j++) {
                a[i][(i + j) % m] = c[j];
                //ad[i][(i + j) % m] = d[j];
            }
        }

        int[][] x = binpow(a, l-2);
        int[][] y = mult(b, x);

        int ans = 0;
        for (int i = 0; i < m; i++)
            for (int j = 0; j < n; j++)
                if ((i+a1[j]+a2[j])%m == 0) {
                    ans += y[0][i];
                    ans %= mod;
                }

//        for (int i = 0; i < m; i++) {
//            for (int j = 0; j < m; j++)
//                System.err.print(y[i][j] + " ");
//            System.err.println();
//        }

        out.println(ans);
    }

    int[][] mult(int[][] a, int[][] b) {
        int n = a.length;
        int[][] c = new int[n][n];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                    c[i][j] = add(c[i][j], mult(a[i][k], b[k][j]));
        return c;
    }

    int[][] binpow(int[][] a, int n) {

        if (n == 0) {
            int[][] c = new int[a.length][a.length];
            for (int i = 0; i < a.length; i++)
                c[i][i] = 1;
            return c;
        }

        if (n == 1)
            return a;
        if (n%2 == 1) return mult(a, binpow(a, n-1));
        int[][] r = binpow(a, n/2);
        return mult(r, r);
    }

    int add(int a, int b) {
        return (a+b)%mod;
    }

    int mult(int a, int b) {
        return (int)((1l*a*b)%mod);
    }


    class Pair implements Comparable<Pair>{

        int a;
        int b;

        Pair(int a, int b) {

            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {

            if (b > p.b) return 1;
            if (b < p.b) return -1;
            if (a > p.a) return 1;
            if (a < p.a) return -1;
            return 0;
        }
    }

    class Item {

        int a;
        int b;
        int c;

        Item(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

    }

    class Reader {

        BufferedReader  br;
        StringTokenizer tok;

        Reader(String file) throws IOException {
            br = new BufferedReader( new FileReader(file) );
        }

        Reader() throws IOException {
            br = new BufferedReader( new InputStreamReader(System.in) );
        }

        String next() throws IOException {

            while (tok == null || !tok.hasMoreElements())
                tok = new StringTokenizer(br.readLine());
            return tok.nextToken();
        }

        int nextInt() throws NumberFormatException, IOException {
            return Integer.valueOf(next());
        }

        long nextLong() throws NumberFormatException, IOException {
            return Long.valueOf(next());
        }

        double nextDouble() throws NumberFormatException, IOException {
            return Double.valueOf(next());
        }


        String nextLine() throws IOException {
            return br.readLine();
        }

    }

}