|
#include <iostream>
using namespace std;
const int maxn=1001;
int c[maxn][maxn];
int T,n,m;
 int lowBit(int i) {return i&(-i);}

void add(int i,int j,int val)
  {
while(i>0)
 {
int temp=j;
while(temp>0)
 {
c[i][temp]+=val;
temp-=lowBit(temp);
}
i-=lowBit(i);
}
}

int sum(int i,int j)
  {
int s=0;
while(i<=n)
 {
int temp=j;
while(temp<=n)
 {
s+=c[i][temp];
temp+=lowBit(temp);
}
i+=lowBit(i);
}
return s%2;
}

int main()
  {

scanf("%d",&T);
while(T--)
 {
memset(c,0,sizeof(c));
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
 {
char s;
scanf("%s",&s);
if(s=='C')
 {
int x1,y1,x2,y2;
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
add(x2,y2,1);
add(x1-1,y2,-1);
add(x2,y1-1,-1);
add(x1-1,y1-1,1);
}
if(s=='Q')
 {
int x,y;
scanf("%d%d",&x,&y);
printf("%d\n",sum(x,y));
}
}
printf("\n");
}
return 0;
}
|