#include <bits/stdc++.h>
using namespace std;
bool exitInput = false;
int ntest = 1, itest = 1;
const int dx[2][3] = {{+0, +1, +1}, {+0, +1, +1}};
const int dy[2][3] = {{+1, +1, +0}, {-1, -1, +0}};
const long long Mod = 1e9 + 7;
const int maxn = 1000 + 5;
const int maxv = 10000 + 5;
const int maxe = 10000 + 5;
int n, m;
long long ft[maxn][maxn][4], arr[maxn][maxn];
int eval(int x) { return x % 2; }
void update(int x, int y, int a, int b, int c, int d) {
  int the = y;
  for (; x < maxn; x += x & -x) {
    y = the;
    for (; y < maxn; y += y & -y) {
      ft[x][y][0] ^= a;
      ft[x][y][1] ^= b;
      ft[x][y][2] ^= c;
      ft[x][y][3] ^= d;
    }
  }
}
long long query(int x, int y) {
  int savex = x, savey = y, a = 0, b = 0, c = 0, d = 0;
  for (; x > 0; x -= x & -x) {
    for (y = savey; y > 0; y -= y & -y) {
      a ^= ft[x][y][0];
      b ^= ft[x][y][1];
      c ^= ft[x][y][2];
      d ^= ft[x][y][3];
    }
  }
  x = savex;
  y = savey;
  return (a * (eval(x) * eval(y))) ^ (b * eval(x)) ^ (c * eval(y)) ^ (d);
}
int main() {
  scanf("%d %d", &n, &m);
  memset(arr, 0, sizeof(arr));
  while (m--) {
    int id, p, q, i, j, r, c, x, y;
    long long v;
    scanf("%d %d %d", &id, &p, &q);
    if (id == 2) {
      scanf("%d %d %I64d", &r, &c, &v);
      x = p;
      y = q;
      update(x, y, v, eval(y - 1) * v, eval(x - 1) * v,
             eval(x - 1) * eval(y - 1) * v);
      x = r + 1;
      y = q;
      update(x, y, v, eval(y - 1) * v, eval(x - 1) * v,
             eval(x - 1) * eval(y - 1) * v);
      x = p;
      y = c + 1;
      update(x, y, v, eval(y - 1) * v, eval(x - 1) * v,
             eval(x - 1) * eval(y - 1) * v);
      x = r + 1;
      y = c + 1;
      update(x, y, v, eval(y - 1) * v, eval(x - 1) * v,
             eval(x - 1) * eval(y - 1) * v);
    } else {
      scanf("%d %d", &r, &c);
      long long pq = query(p - 1, q - 1);
      long long rc = query(r, c);
      long long tmp1 = query(p - 1, c);
      long long tmp2 = query(r, q - 1);
      long long res = pq ^ rc ^ tmp1 ^ tmp2;
      printf("%I64d\n", res);
    }
  }
  fclose(stdout);
  fclose(stdin);
  return 0;
}
