#include <bits/stdc++.h>
using namespace std;
const int maxn = 1050;
long long c[2][2][maxn][maxn];
int n, q;
int lowbit(int x) { return x & (-x); }
void upd(int x, int y, long long d) {
  for (int i = x; i <= n; i += lowbit(i)) {
    for (int j = y; j <= n; j += lowbit(j)) {
      c[x & 1][y & 1][i][j] ^= d;
    }
  }
}
long long query(int x, int y) {
  long long ret = 0;
  for (int i = x; i; i -= lowbit(i)) {
    for (int j = y; j; j -= lowbit(j)) {
      ret ^= c[x & 1][y & 1][i][j];
    }
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> q;
  while (q--) {
    int op, x1, y1, x2, y2;
    cin >> op >> x1 >> y1 >> x2 >> y2;
    if (op == 1) {
      cout << (query(x2, y2) ^ query(x1 - 1, y2) ^ query(x2, y1 - 1) ^
               query(x1 - 1, y1 - 1))
           << "\n";
    }
    if (op == 2) {
      long long d;
      cin >> d;
      upd(x1, y1, d);
      upd(x2 + 1, y1, d);
      upd(x1, y2 + 1, d);
      upd(x2 + 1, y2 + 1, d);
    }
  }
  return 0;
}
