# coding: utf-8 # Your code here! import sys sys.setrecursionlimit(10**6) readline = sys.stdin.readline read = sys.stdin.read p,n,k,b,*a = [int(i) for i in read().split()] lst = [0]*p for i in range(p): lst[pow(i,k,p)] += 1 MOD = 10**9+7 x = 1 M = 1<<96 NUM = 96*p ALL = (1<>NUM) + (x&ALL) x -= ((x & m) >> 64) * pa ans = (x>>(b*96))&((1<<96)-1) print(ans%MOD)