#include typedef long long ll; using namespace std; const ll MOD=1e9+7; ll powmod(ll a, ll k, ll mod){ if(a==0) return 0; ll ap=a, ans=1; while(k){ if(k&1){ ans*=ap; ans%=mod; } ap=ap*ap; ap%=mod; k>>=1; } return ans; } ll inv(ll a, ll mod){ return powmod(a, mod-2, mod); } ll gcd(ll a, ll b){ if(b==0) return a; return gcd(b, a%b); } ll a[505], q[100010], dp[100010], tmp[100010]; int qi[100010]; int main() { int n, k; ll b, p; cin>>p>>n>>k>>b; k=gcd(k, p-1); for(int i=0; i>a[i]; ll r; for(r=1; r