#include <bits/stdc++.h>
const int maxn = 1010;
long long f[4][maxn + 1][maxn + 1];
int n, m;
int calc_bh(int x, int y) {
  int t = 0;
  if (x & 1) ++t;
  if (y & 1) t += 2;
  return t;
}
int lowbit(int x) { return (x & (x ^ (x - 1))); }
void ins(int x, int y, long long v) {
  int i, j, t;
  t = calc_bh(x, y);
  for (i = x; i <= n; i += lowbit(i))
    for (j = y; j <= n; j += lowbit(j)) f[t][i][j] = (f[t][i][j] ^ v);
}
long long ask(int x, int y) {
  int i, j, t;
  long long result = 0;
  t = calc_bh(x, y);
  for (i = x; i >= 1; i -= lowbit(i))
    for (j = y; j >= 1; j -= lowbit(j)) result = (f[t][i][j] ^ result);
  return result;
}
void init() {
  int t, i, j;
  scanf("%d%d", &n, &m);
  for (t = 0; t < 4; ++t)
    for (i = 1; i <= n; ++i)
      for (j = 1; j <= n; ++j) f[t][i][j] = 0;
}
void work() {
  int w, t, x1, y1, x2, y2;
  long long v;
  for (w = 1; w <= m; ++w) {
    scanf("%d%d%d%d%d", &t, &x1, &y1, &x2, &y2);
    if (t == 1)
      printf("%lld\n", ask(x2, y2) ^ ask(x2, y1 - 1) ^ ask(x1 - 1, y2) ^
                           ask(x1 - 1, y1 - 1));
    else {
      scanf("%lld", &v);
      ins(x1, y1, v);
      ins(x1, y2 + 1, v);
      ins(x2 + 1, y1, v);
      ins(x2 + 1, y2 + 1, v);
    }
  }
}
int main() {
  init();
  work();
  return 0;
}
