import sys import math MOD = 10**9 + 7 def main(): p, n, k, b = map(int, sys.stdin.readline().split()) a_list = list(map(int, sys.stdin.readline().split())) d = math.gcd(k, p-1) # Precompute H: residues of x^k mod p for x in 0..p-1 H = set() for x in range(p): res = pow(x, k, p) H.add(res) H = sorted(H) terms = [] for ai in a_list: if ai == 0: terms.append({0: p}) else: freq = {} freq[0] = 1 # x=0 for h in H: if h == 0: continue c = (ai * h) % p if c in freq: freq[c] += d else: freq[c] = d terms.append(freq) dp = [0] * p dp[0] = 1 for term in terms: new_dp = [0] * p for s in range(p): if 0 in term: cnt0 = term[0] new_dp[s] = (new_dp[s] + dp[s] * cnt0) % MOD for c in term: if c == 0: continue prev_s = (s - c) % p new_dp[s] = (new_dp[s] + dp[prev_s] * term[c]) % MOD dp = new_dp print(dp[b] % MOD) if __name__ == "__main__": main()