# 1. 题目

1. 给定一个矩形区域，该区域内的 0 变成 1，1 变成 0（区间异或）
2. 询问某个位置的值为 0 还是 1

$N\leq 1000, M\leq 50000$

# 2. 题解

#include <cstdio>
#include <cctype>
#include <cstring>

#define NS (1005)
#define lowbit(a) (a & -a)

using namespace std;

template <typename _Tp> inline void IN(_Tp& dig)
{
char c; bool flag = 0; dig = 0;
while (c = getchar(), !isdigit(c)) if (c == '-') flag = 1;
while (isdigit(c)) dig = dig * 10 + c - '0', c = getchar();
if (flag) dig = -dig;
}

int T, n, m;

char opt[3];

bool t[NS][NS];

void Rev(int a, int b)
{
for (int i = a; i <= n; i += lowbit(i))
for (int j = b; j <= n; j += lowbit(j))
t[i][j] ^= 1;
}

int sum(int a, int b)
{
int res = 0;
for (int i = a; i; i -= lowbit(i))
for (int j = b; j; j -= lowbit(j))
res ^= t[i][j];
return res;
}

int main(int argc, char const* argv[])
{
IN(T);
while (T--)
{
IN(n), IN(m), memset(t, 0, sizeof(t));
for (int i = 1, a, b, c, d; i <= m; i += 1)
{
scanf("%s", opt), IN(a), IN(b);
if (opt[0] == 'C')
{
IN(c), IN(d);
Rev(a, b), Rev(c + 1, d + 1);
Rev(a, d + 1), Rev(c + 1, b);
}
else printf("%d\n", sum(a, b));
}
putchar(10);
}
return 0;
}