#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n, m;
int c[2][2][maxn][maxn];
void update(int x1, int y1, long long v) {
  for (int i = x1; i <= n; i += i & -i) {
    for (int j = y1; j <= n; j += j & -j) {
      c[x1 & 1][y1 & 1][i][j] ^= v;
    }
  }
}
int query(int x, int y) {
  int res = 0;
  for (int i = x; i > 0; i -= i & -i) {
    for (int j = y; j > 0; j -= j & -j) {
      res ^= c[x & 1][y & 1][i][j];
    }
  }
  return res;
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    int q, x0, y0, x1, y1;
    long long v;
    memset(c, 0, sizeof(c));
    ;
    for (int i = 1; i <= m; i++) {
      scanf("%d", &q);
      if (q == 2) {
        scanf("%d%d%d%d%I64d", &x0, &y0, &x1, &y1, &v);
        update(x0, y0, v);
        update(x0, y1 + 1, v);
        update(x1 + 1, y0, v);
        update(x1 + 1, y1 + 1, v);
      } else {
        scanf("%d%d%d%d", &x0, &y0, &x1, &y1);
        long long ans = query(x1, y1) ^ query(x0 - 1, y1) ^ query(x1, y0 - 1) ^
                        query(x0 - 1, y0 - 1);
        cout << ans << endl;
      }
    }
  }
}
