#include "bits/stdc++.h" /* #include "boost/multiprecision/cpp_int.hpp" namespace mp = boost::multiprecision; using i128=mp::cpp_int; */ using namespace std; typedef long long ll; typedef int64_t i64; typedef vector vi; typedef vector vvi; typedef vector vvvi; typedef vector vll; typedef vector vvll; typedef vector vvvll; typedef vector vs; typedef vector vc; typedef vector vvc; typedef vector vd; typedef vector vvd; #define rep(i,a,n) for(int i=a;in;i--) #define yes(ans) if(ans)cout<<"yes"<0){ if(n%2==1){ans*=change; ans%=m;} change*=change; change%=m; n/=2; } return ans; } int main(){ ll n,p,q; cin>>n>>p>>q; vll a(n+1); rep(i,1,n+1) cin>>a[i]; vvvll dp(2,vvll(p,vll(5))); dp[0][0][0]=1; rep(i,1,n+1){ vll mod(5); mod[1]=modexpo(10,a[i],p); mod[2]=modexpo(9,a[i],p); mod[3]=modexpo(7,a[i],p); mod[4]=modexpo(5,a[i],p); ll I=i%2,J=(i+1)%2; rep(j,0,p){ rep(k,0,5){ dp[I][j][k]=dp[J][j][k]; } dp[I][j][1]+=dp[J][(j-mod[1]+p)%p][0]; dp[I][j][2]+=dp[J][(j-mod[2]+p)%p][1]; dp[I][j][3]+=dp[J][(j-mod[3]+p)%p][2]; dp[I][j][4]+=dp[J][(j-mod[4]+p)%p][3]; } } cout<