#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include using namespace std; ll p; ll dp[200020][40]; pair f(ll x){ int c=1; while(x%p==0){ x/=p; c++; } return {x,c}; } int main(){ ll n,m; cin>>n>>m>>p; vector A(n); rep(i,n) cin>>A[i]; ll ma=0; rep(i,n) ma=max(ma,A[i]); if(ma>m){ cout<<1<> B(n); rep(i,n) B[i]=f(A[i]); ll ma1=0; rep(i,n) ma1=max(ma1,B[i].first); if(ma1<2){ cout<<-1<=0 && (j-1)%B[i].second==0){ dp[i][j]=dp[i][j-B[i].second]*B[i].first; if(dp[i][j]>g){ cout<