← Home
package main

import (
	"bufio"
	"fmt"
	"os"
)

const MOD int64 = 1000000007

type FastScanner struct {
	r *bufio.Reader
}

func NewFastScanner() *FastScanner {
	return &FastScanner{r: bufio.NewReaderSize(os.Stdin, 1<<20)}
}

func (fs *FastScanner) NextInt() int {
	sign, val := 1, 0
	c, _ := fs.r.ReadByte()
	for (c < '0' || c > '9') && c != '-' {
		c, _ = fs.r.ReadByte()
	}
	if c == '-' {
		sign = -1
		c, _ = fs.r.ReadByte()
	}
	for c >= '0' && c <= '9' {
		val = val*10 + int(c-'0')
		c2, err := fs.r.ReadByte()
		if err != nil {
			break
		}
		if c2 < '0' || c2 > '9' {
			break
		}
		c = c2
	}
	return sign * val
}

func matMul(a, b [][]int64) [][]int64 {
	n := len(a)
	c := make([][]int64, n)
	for i := 0; i < n; i++ {
		c[i] = make([]int64, n)
	}
	for i := 0; i < n; i++ {
		ai := a[i]
		ci := c[i]
		for k := 0; k < n; k++ {
			if ai[k] == 0 {
				continue
			}
			aik := ai[k]
			bk := b[k]
			for j := 0; j < n; j++ {
				if bk[j] == 0 {
					continue
				}
				ci[j] = (ci[j] + aik*bk[j]) % MOD
			}
		}
	}
	return c
}

func matPow(base [][]int64, exp int64) [][]int64 {
	n := len(base)
	res := make([][]int64, n)
	for i := 0; i < n; i++ {
		res[i] = make([]int64, n)
		res[i][i] = 1
	}
	for exp > 0 {
		if exp&1 == 1 {
			res = matMul(res, base)
		}
		base = matMul(base, base)
		exp >>= 1
	}
	return res
}

func main() {
	in := NewFastScanner()
	n := in.NextInt()
	b := int64(in.NextInt())
	k := in.NextInt()
	x := in.NextInt()

	cnt := make([]int64, 10)
	for i := 0; i < n; i++ {
		d := in.NextInt()
		cnt[d]++
	}

	t := make([][]int64, x)
	for i := 0; i < x; i++ {
		t[i] = make([]int64, x)
	}
	for old := 0; old < x; old++ {
		for d := 1; d <= 9; d++ {
			if cnt[d] == 0 {
				continue
			}
			nr := (old*10 + d) % x
			t[nr][old] = (t[nr][old] + cnt[d]) % MOD
		}
	}

	p := matPow(t, b)

	out := bufio.NewWriterSize(os.Stdout, 1<<20)
	fmt.Fprintln(out, p[k][0]%MOD)
	out.Flush()
}