#include <bits/stdc++.h>
using namespace std;
int n, m;
long long tree[4][1002][1002];
int lb(int x) { return x & (x ^ (x - 1)); }
long long calc2(int id, int x, int y) {
  int i, temp = 0;
  for (i = y; i > 0; i -= lb(i)) {
    temp ^= tree[id][x][i];
  }
  return temp;
}
long long calc1(int id, int x, int y) {
  int i, temp = 0;
  for (i = x; i > 0; i -= lb(i)) {
    temp ^= calc2(id, i, y);
  }
  return temp;
}
void inc2(int id, int x, int y, long long v) {
  int i;
  for (i = y; i <= n; i += lb(i)) {
    tree[id][x][i] ^= v;
  }
  return;
}
void inc1(int id, int x, int y, long long v) {
  int i;
  for (i = x; i <= n; i += lb(i)) {
    inc2(id, i, y, v);
  }
  return;
}
long long get_ans(int x0, int y0, int x1, int y1) {
  int i, j;
  long long temp = 0;
  int id;
  id = (((x0 - 1) % 2) << 1) + ((y0 - 1) % 2);
  temp ^= calc1(id, x0 - 1, y0 - 1);
  id = (((x0 - 1) % 2) << 1) + (y1 % 2);
  temp ^= calc1(id, x0 - 1, y1);
  id = ((x1 % 2) << 1) + ((y0 - 1) % 2);
  temp ^= calc1(id, x1, y0 - 1);
  id = ((x1 % 2) << 1) + (y1 % 2);
  temp ^= calc1(id, x1, y1);
  return temp;
}
int main() {
  int i, j, k, id;
  int xx, x0, y0, x1, y1;
  long long v;
  scanf("%d %d", &n, &m);
  memset(tree, 0, sizeof(long long) * 4 * 1002 * 1002);
  for (i = 1; i <= m; i++) {
    scanf("%d", &xx);
    if (xx == 1) {
      scanf("%d %d %d %d", &x0, &y0, &x1, &y1);
      printf("%I64d\n", get_ans(x0, y0, x1, y1));
    } else {
      scanf("%d %d %d %d %I64d", &x0, &y0, &x1, &y1, &v);
      id = ((x0 % 2) << 1) + (y0 % 2);
      inc1(id, x0, y0, v);
      id = ((x0 % 2) << 1) + ((y1 + 1) % 2);
      inc1(id, x0, y1 + 1, v);
      id = (((x1 + 1) % 2) << 1) + (y0 % 2);
      inc1(id, x1 + 1, y0, v);
      id = (((x1 + 1) % 2) << 1) + ((y1 + 1) % 2);
      inc1(id, x1 + 1, y1 + 1, v);
    }
  }
  return 0;
}
