intgcd(inta,intb){returna?gcd(b%a,a):b;}intpowmod(inta,intb,intp){intres=1;while(b>0){if(b&1)res=res*a%p;a=a*a%p,b>>=1;}returnres;}// Finds the primitive root modulo pintgenerator(intp){vector<int>fact;intphi=p-1,n=phi;for(inti=2;i*i<=n;++i){if(n%i==0){fact.push_back(i);while(n%i==0)n/=i;}}if(n>1)fact.push_back(n);for(intres=2;res<=p;++res){boolok=true;for(intfactor:fact){if(powmod(res,phi/factor,p)==1){ok=false;break;}}if(ok)returnres;}return-1;}// This program finds all numbers x such that x^k=a (mod n)intmain(){intn,k,a;scanf("%d %d %d",&n,&k,&a);if(a==0)returnputs("1\n0"),0;intg=generator(n);// Baby-step giant-step discrete logarithm algorithmintsq=(int)sqrt(n+.0)+1;vector<pair<int,int>>dec(sq);for(inti=1;i<=sq;++i)dec[i-1]={powmod(g,i*sq*k%(n-1),n),i};sort(dec.begin(),dec.end());intany_ans=-1;for(inti=0;i<sq;++i){intmy=powmod(g,i*k%(n-1),n)*a%n;autoit=lower_bound(dec.begin(),dec.end(),make_pair(my,0));if(it!=dec.end()&&it->first==my){any_ans=it->second*sq-i;break;}}if(any_ans==-1)returnputs("0"),0;// Print all possible answersintdelta=(n-1)/gcd(k,n-1);vector<int>ans;for(intcur=any_ans%delta;cur<n-1;cur+=delta)ans.push_back(powmod(g,cur,n));sort(ans.begin(),ans.end());printf("%d\n",ans.size());for(intanswer:ans)printf("%d ",answer);}