#include using namespace std; #define REP(i,a,b) for(i=a;i'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(double *x){scanf("%lf",x);} int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;} template void reader(T *x, S *y){reader(x);reader(y);} template void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);} template void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);} void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(double x, char c){printf("%.15f",x);mypc(c);} void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);} void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);} template void writerLn(T x){writer(x,'\n');} template void writerLn(T x, S y){writer(x,' ');writer(y,'\n');} template void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');} template void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');} char memarr[57000000]; void *mem = memarr; #define MD 1000000007 int maxIndependenceSet(int n, int *es, int **edge, int *res, void *mem, int lim=-1){int i,j,k,f=1,x,y,z=0,U,s,T,*r,*d,*c,*e,*u,*W,**G;pair*p;void*E;if(n==0||n<=lim)return 0;if(n==1){res[0]=0;return 1;}r=(int*)mem;d=r+n;c=d+n;e=c+n;u=e+n;p=(pair*)(u+n);mem=p+n;rep(i,n)if(es[i]<=1)break;if(i=0)G[i][W[i]++]=x;}s=maxIndependenceSet(U,W,G,d,E,max(-1,lim-z));rep(i,s)res[z++]=u[d[i]];return z;}if(lim>=1){rep(i,n)e[i]=es[i];sort(e,e+n);s=0;rep(k,n)s+=es[k];j=0;rep(i,n){j+=e[i];if(2*j>s)break;}if(i<=lim)return z;rep(i,n)if(e[i]>n-i-1)break;if(i<=lim)return z;}rep(i,n)r[i]=-1;x=0;rep(i,n)if(r[i]==-1){s=1;e[0]=i;r[i]=i;x++;while(s){k=e[--s];rep(j,es[k])if(r[edge[k][j]]==-1)r[edge[k][j]]=i,e[s++]=edge[k][j];}}if(x>1){rep(i,n)e[i]=0;k=0;rep(i,n){j=r[i];if(e[j]==0)k++;e[j]++;}rep(i,n)p[i].first=e[i],p[i].second=i;sort(p,p+n);T=n;rep(y,n)if(p[y].first){k=p[y].second;U=0;rep(i,n)if(r[i]==k)u[U++]=i;rep(i,n)c[i]=-1;rep(i,U)c[u[i]]=i;W=(int*)mem;G=(int**)(W+U);G[0]=(int*)(G+U);REP(i,1,U)G[i]=G[i-1]+es[u[i-1]];E=G[U-1]+es[u[U-1]];rep(i,U)W[i]=0;rep(i,U)rep(j,es[u[i]]){x=c[edge[u[i]][j]];if(x>=0)G[i][W[i]++]=x;}T-=U;s=maxIndependenceSet(U,W,G,d,E,max(-1,lim-T-z));rep(i,s)res[z++]=u[d[i]];}return z;}k=0;REP(i,1,n)if(es[k]=0)G[i][W[i]++]=x;}s=maxIndependenceSet(U,W,G,d,E,max(lim-1,z-1));if(z=0)G[i][W[i]++]=x;}s=maxIndependenceSet(U,W,G,d,E,max(lim-1,z-1));if(z=0)G[i][W[i]++]=x;}s=maxIndependenceSet(U,W,G,d,E,max(lim,z));if(z void *malloc1d(T **arr, int x, void *mem){(*arr)=(T*)mem;return((*arr)+x);} template void *malloc2d(T ***arr, int x, int y, void *mem){int i;(*arr)=(T**)mem;(*arr)[0]=(T*)((*arr)+x);REP(i,1,x)(*arr)[i]=(*arr)[i-1]+y;return((*arr)[x-1]+y);} ll S; int get_next(void){ S = S * 12345 % 1000003; return S; } int main(){ int i, j, k; int res, arr[200]; int N, P; int *es, **edge, **mat; mem = malloc1d(&es, 130, mem); mem = malloc2d(&edge, 130, 130, mem); mem = malloc2d(&mat, 130, 130, mem); reader(&S); N = get_next() % 120 + 2; P = get_next(); rep(i,N) rep(j,N) mat[i][j] = 0; rep(i,N) REP(j,i+1,N){ k = get_next(); if(k >= P) mat[i][j] = mat[j][i] = 1; } rep(i,N) es[i] = 0; rep(i,N) rep(j,N) if(mat[i][j]) edge[i][es[i]++] = j; res = maxIndependenceSet(N, es, edge, arr, mem); if(res==N){ writerLn(-1); } else { writerLn(res+1); rep(i,res) arr[i]++; sort(arr, arr+res); writerArr(arr,res); } return 0; }