#include #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define all(c) c.begin(),c.end() #define pb push_back #define fs first #define sc second #define show(x) cout << #x << " = " << x << endl #define chmin(x,y) x=min(x,y) #define chmax(x,y) x=max(x,y) using namespace std; template ostream& operator<<(ostream& o,const pair &p){return o<<"("< ostream& operator<<(ostream& o,const vector &vc){o<<"sz = "< E[128]; unsigned long long seed = 1145141919810893ULL; int xor_rand(){ seed = seed ^ (seed<<13); seed = seed ^ (seed>>7); seed = seed ^ (seed<<17); return (seed>>33); } int main(){ Timer timer; timer.start(); cin>>S; N = next()%120 + 2; P = next(); rep(i,N) for(int j=i+1;j=P) E[i].set(j),E[j].set(i); //1:cannot vector p(N); rep(i,N) p[i] = i; vector ans; int prevt = timer.ms(); while(true){ int t = timer.ms(); if(t + (t-prevt) >= 2000) break; prevt = t; rep(tt,5000){ bitset<128> B; vector tmp; rep(j,N) swap(p[j],p[xor_rand()%(j+1)]); rep(j,N) if(!B[p[j]]){ tmp.pb(p[j]); B |= E[p[j]]; } if(tmp.size()>ans.size()) ans = tmp; } } if(ans.size()==N){ puts("-1"); return 0; } int K = ans.size(); cout<