#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
const int mod = (int)1e9 + 7;
const int logN = 18;
const int inf = 1e9;
const int N = 1e3 + 5;
int n, m, S[N], x, y, a, b, t, q, F[2][2][N][N];
void upd(int x, int r, int k) {
  int t1 = x & 1, t2 = r & 1;
  for (; x <= n + 1 && x; x += x & -x)
    for (int y = r; y <= n + 1 && y; y += y & -y) F[t1][t2][x][y] ^= k;
}
int que(int x, int r) {
  int t1 = x & 1, t2 = r & 1, ans = 0;
  for (; x; x -= x & -x)
    for (int y = r; y; y -= y & -y) ans ^= F[t1][t2][x][y];
  return ans;
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d%d%d%d", &x, &y, &a, &b);
      printf("%d\n",
             que(a, b) ^ que(a, y - 1) ^ que(x - 1, b) ^ que(x - 1, y - 1));
    } else {
      scanf("%d%d%d%d%d", &x, &y, &a, &b, &t);
      upd(a + 1, b + 1, t), upd(a + 1, y, t), upd(x, b + 1, t), upd(x, y, t);
    }
  }
}
