#include <bits/stdc++.h>
using namespace std;
const int sz = 9, n = (1 << sz) - 1;
long long nd[2][2][n + 1][n + 1] = {0};
void upd(int i, int j, long long val) {
  for (int ii = i / 2 + 1; ii <= n; ii += (ii & -ii))
    for (int jj = j / 2 + 1; jj <= n; jj += (jj & -jj))
      nd[i % 2][j % 2][ii][jj] ^= val;
}
long long suff(int i, int j) {
  long long res = 0LL;
  for (int ii = i / 2; ii; ii -= (ii & -ii))
    for (int jj = j / 2; jj; jj -= (jj & -jj)) res ^= nd[i % 2][j % 2][ii][jj];
  return res;
}
int main() {
  int mm;
  scanf("%*d %d", &mm);
  for (int ii = 0; ii < mm; ii++) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      int x0, y0, x1, y1;
      scanf("%d %d %d %d", &x0, &y0, &x1, &y1);
      x1++;
      y1++;
      long long ans = 0LL;
      ans ^= suff(x0, y0);
      ans ^= suff(x0, y1);
      ans ^= suff(x1, y0);
      ans ^= suff(x1, y1);
      printf("%lld\n", ans);
    } else if (op == 2) {
      int x0, y0, x1, y1;
      long long v;
      scanf("%d %d %d %d %lld", &x0, &y0, &x1, &y1, &v);
      x0--;
      y0--;
      upd(x0, y0, v);
      upd(x0, y1, v);
      upd(x1, y0, v);
      upd(x1, y1, v);
    }
  }
  return 0;
}
