#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<sstream> #include<algorithm> #include<queue> #include<deque> #include<iomanip> #include<vector> #include<cmath> #include<map> #include<stack> #include<set> #include<fstream> #include<memory> #include<list> #include<string> using namespace std; typedef long long LL; typedef unsigned long long ULL; #define MAXN 1000 + 23 #define L 31 #define INF 1000000009 #define eps 0.00000001 #define sf(a) scanf("%d",&a) int T, n, k; int a[MAXN][MAXN]; char op[2]; inline int lowbit(int x) { return x&(-x); } void update(int x, int y) { for (int i = x; i < MAXN; i += lowbit(i) ) { for (int j = y; j < MAXN; j += lowbit(j) ) { a[i][j]++; } } } int query(int x, int y) { int sum = 0; for (int i = x; i > 0; i -= lowbit(i)) { for (int j = y; j > 0; j -= lowbit(j)) { sum += a[i][j]; } } return sum; } int main() { int x1, y1, x2, y2; sf(T); while (T--) { memset(a, 0, sizeof(a)); sf(n), sf(k); for (int i = 0; i < k; i++) { scanf("%s", op); if (op[0] == 'C') { sf(x1), sf(y1), sf(x2), sf(y2); x1++, y1++, x2++, y2++;//避免出现0 update(x1, y1); update(x1, y2 + 1); update(x2 + 1, y1); update(x2 + 1, y2 + 1);//重叠的部分加上 } else { sf(x1), sf(y1); x1++, y1++; printf("%d ", query(x1, y1) % 2); } } cout << endl; } }