#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int MOD = 1000000007;
const double EPS = 1e-9;
int n, m;
long long a[4][1024][1024], v;
long long query(int x, int y) {
  int t = (x & 1) << 1 | y & 1;
  long long res = 0;
  for (int i = x; i >= 1; i -= i & -i)
    for (int j = y; j >= 1; j -= j & -j) res ^= a[t][i][j];
  return res;
}
void modify(int x, int y) {
  int t = (x & 1) << 1 | y & 1;
  for (int i = x; i <= n; i += i & -i)
    for (int j = y; j <= n; j += j & -j) a[t][i][j] ^= v;
}
int main() {
  int op, x0, y0, x1, y1;
  scanf("%d%d", &n, &m);
  while (m--) {
    scanf("%d%d%d%d%d", &op, &x0, &y0, &x1, &y1);
    if (op == 1) {
      x0--, y0--;
      cout << (query(x0, y0) ^ query(x1, y0) ^ query(x0, y1) ^ query(x1, y1))
           << endl;
    } else {
      cin >> v;
      x1++, y1++;
      modify(x0, y0), modify(x1, y0), modify(x0, y1), modify(x1, y1);
    }
  }
  return 0;
}
