1 #include<cstdio>
2 #include<iostream>
3 #include<cmath>
4 #include<cstring>
5 #include<algorithm>
6 #define maxn 100005
7 using namespace std;
8 char ch;
9 int n,T,tmp,f,x,sg[maxn];
10 bool bo[maxn*320],ok,first=1;
11 void read(int &x){
12 for (ok=0,ch=getchar();!isdigit(ch);ch=getchar()) if (ch==‘-‘) ok=1;
13 for (x=0;isdigit(ch);x=x*10+ch-‘0‘,ch=getchar());
14 if (ok) x=-x;
15 }
16 void calc(int n){
17 if (n<f){sg[n]=0;return;}
18 for (int i=2;i<=n;i=n/(n/i)+1)
19 for (int j=i;j<=i+1&&j<=n;j++){
20 if (((n%j)&1)&&sg[n/j+1]==-1) calc(n/j+1);
21 if (((j-n%j)&1)&&sg[n/j]==-1) calc(n/j);
22 }
23 for (int i=2;i<=n;i=n/(n/i)+1)
24 for (int j=i,t;j<=i+1&&j<=n;j++){
25 t=0;
26 if ((n%j)&1) t^=sg[n/j+1];
27 if ((j-n%j)&1) t^=sg[n/j];
28 bo[t]=1;
29 }
30 for (int i=0;;i++) if (!bo[i]){sg[n]=i;break;}
31 for (int i=2;i<=n;i=n/(n/i)+1)
32 for (int j=i,t;j<=i+1&&j<=n;j++){
33 t=0;
34 if ((n%j)&1) t^=sg[n/j+1];
35 if ((j-n%j)&1) t^=sg[n/j];
36 bo[t]=0;
37 }
38 }
39 int main(){
40 memset(sg,-1,sizeof(sg));
41 for (read(T),read(f);T;T--){
42 read(n),tmp=0;
43 for (int i=1;i<=n;i++){
44 read(x);
45 if (sg[x]==-1) calc(x);
46 tmp^=sg[x];
47 }
48 if (first) first=0;
49 else putchar(‘ ‘);
50 printf("%d",(tmp!=0));
51 }
52 puts("");
53 return 0;
54 }