#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int NUM = 1e3 + 10;
int tree[4][NUM][NUM];
int n, m;
inline int lowbit(int x) { return x & (-x); }
inline int turn(int x, int y) { return (x & 1) + ((y & 1) << 1); }
void update(int type, int x, int y, int w) {
  while (x <= n) {
    int tmp = y;
    while (tmp <= n) {
      tree[type][x][tmp] ^= w;
      tmp += lowbit(tmp);
    }
    x += lowbit(x);
  }
}
int query(int type, int x, int y) {
  int ans = 0;
  while (x) {
    int tmp = y;
    while (tmp) {
      ans ^= tree[type][x][tmp];
      tmp -= lowbit(tmp);
    }
    x -= lowbit(x);
  }
  return ans;
}
void update(int x1, int y1, int x2, int y2, int w) {
  int t1 = turn(x2 + 1, y2 + 1), t2 = turn(x2 + 1, y1), t3 = turn(x1, y2 + 1),
      t4 = turn(x1, y1);
  update(t1, x2 + 1, y2 + 1, w);
  update(t2, x2 + 1, y1, w);
  update(t3, x1, y2 + 1, w);
  update(t4, x1, y1, w);
}
int query(int x1, int y1, int x2, int y2) {
  int ans = 0;
  int t1 = turn(x2, y2), t2 = turn(x2, y1 - 1), t3 = turn(x1 - 1, y2),
      t4 = turn(x1 - 1, y1 - 1);
  ans ^= query(t1, x2, y2);
  ans ^= query(t2, x2, y1 - 1);
  ans ^= query(t3, x1 - 1, y2);
  ans ^= query(t4, x1 - 1, y1 - 1);
  return ans;
}
int main() {
  int op, x1, x2, y1, y2, w;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &op);
    if (op == 2) {
      scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &w);
      update(x1, y1, x2, y2, w);
    } else {
      scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
      cout << query(x1, y1, x2, y2) << endl;
    }
  }
}
