#include <bits/stdc++.h>
int t[2][2][4004][4004], n, m;
int sum(int r, int c) {
  int ret = 0;
  for (int rr = r; rr; rr -= ((rr) & (-(rr))))
    for (int cc = c; cc; cc -= ((cc) & (-(cc)))) ret ^= t[r & 1][c & 1][rr][cc];
  return ret;
}
void add(int r, int c, int v) {
  for (int rr = r + 1; rr < 4 * (n + 1); rr += ((rr) & (-(rr))))
    for (int cc = c + 1; cc < 4 * (n + 1); cc += ((cc) & (-(cc))))
      t[(r + 1) & 1][(c + 1) & 1][rr][cc] ^= v;
}
int main() {
  for (scanf("%d%d", &n, &m); m--;) {
    int op, r1, c1, r2, c2, v;
    scanf("%d%d%d%d%d", &op, &r1, &c1, &r2, &c2);
    --r1;
    --c1;
    if (op == 2) {
      scanf("%d", &v);
      add(r2, c2, v);
      add(r2, c1, v);
      add(r1, c2, v);
      add(r1, c1, v);
    }
    if (op == 1)
      printf("%d\n", sum(r2, c2) ^ sum(r1, c2) ^ sum(r2, c1) ^ sum(r1, c1));
  }
  return 0;
}
