#include <bits/stdc++.h>
const int NS = 1010;
int n, m;
long long s[2][2][NS][NS], w;
long long lowbit(long long x) { return x & (-x); }
void add(int x, int y) {
  for (int i = x; i <= n; i += lowbit(i))
    for (int j = y; j <= n; j += lowbit(j)) s[x & 1][y & 1][i][j] ^= w;
}
long long get(int x, int y) {
  long long ret = 0;
  for (int i = x; i > 0; i -= lowbit(i))
    for (int j = y; j > 0; j -= lowbit(j)) ret ^= s[x & 1][y & 1][i][j];
  return ret;
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    memset(s, 0, sizeof(s));
    for (; m--;) {
      int op, x1, x2, y1, y2;
      scanf("%d%d%d%d%d", &op, &x1, &y1, &x2, &y2);
      if (op == 1) {
        long long ans = get(x1 - 1, y1 - 1) ^ get(x2, y2) ^ get(x2, y1 - 1) ^
                        get(x1 - 1, y2);
        printf("%I64d\n", ans);
      } else {
        scanf("%I64d", &w);
        add(x1, y1);
        add(x1, y2 + 1);
        add(x2 + 1, y1);
        add(x2 + 1, y2 + 1);
      }
    }
  }
  return 0;
}
