#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
long long C[4][maxn][maxn], n, m;
inline int lowbit(int x) { return x & (-x); }
int getw(int x, int y) {
  int ans = 0;
  if (x & 1) ans += 1;
  if (y & 1) ans += 2;
  return ans;
}
void update(int x, int y, long long v) {
  int wh = getw(x, y);
  for (int i = x; i < maxn; i += lowbit(i)) {
    for (int j = y; j < maxn; j += lowbit(j)) {
      C[wh][i][j] ^= v;
    }
  }
}
long long query(int x, int y) {
  int wh = getw(x, y);
  long long ans = 0;
  for (int i = x; i > 0; i -= lowbit(i)) {
    for (int j = y; j > 0; j -= lowbit(j)) {
      ans ^= C[wh][i][j];
    }
  }
  return ans;
}
int main() {
  memset(C, 0, sizeof(C));
  scanf("%lld%lld", &n, &m);
  long long v, x1, y1, x2, y2, p;
  while (m--) {
    scanf("%lld%lld%lld%lld%lld", &p, &x1, &y1, &x2, &y2);
    if (p == 1) {
      long long ans = query(x2, y2);
      ans ^= query(x2, y1 - 1);
      ans ^= query(x1 - 1, y2);
      ans ^= query(x1 - 1, y1 - 1);
      printf("%I64d\n", ans);
    } else {
      scanf("%lld", &v);
      update(x1, y1, v);
      update(x1, y2 + 1, v);
      update(x2 + 1, y1, v);
      update(x2 + 1, y2 + 1, v);
    }
  }
  return 0;
}
