import math p, n, k, b=map(int, input().split()) a=list(map(int, input().split())) r=1 for i in range(1, p): dame=False pp=1 for j in range(p-2): pp*=i pp%=p if pp==1: dame=True break if not dame: r=i break q=[1]*(p-1) qi=[0]*p k=math.gcd(k, p-1) for i in range(1, p-1): q[i]=q[i-1]*r%p for i in range(p-1): qi[q[i]]=i%k dp=[0]*(k+1) dp[k]=1 tmp=[0]*(k+1) MOD=10**9+7 for x in a: for j in range(k+1): tmp[j]=dp[j] for j in range(k): for l in range((p-1)//k): m=(q[l*k]*x+q[j])%p if m==0: tmp[k]+=dp[j]*k tmp[k]%=MOD else: tmp[qi[m]]+=dp[j]*k tmp[qi[m]]%=MOD if x==0: tmp[k]+=dp[k]*(p-1) tmp[k]%=MOD else: tmp[qi[x]]+=dp[k]*(p-1) tmp[qi[x]]%=MOD for j in range(k+1): dp[j]=tmp[j] if b==0: print(dp[k]) else: print(dp[qi[b]]*pow((p-1)//k, MOD-2, MOD)%MOD)