#include <bits/stdc++.h>
const double pi = acos(-1.0);
const double eps = 1e-9;
using namespace std;
const int N = 1e3 + 10;
long long t[2 * N][2 * N][4];
int who(int x, int y) {
  int res = 0;
  if (x % 2) {
    res++;
  }
  if (y % 2) {
    res += 2;
  }
  return res;
}
int sum(int x, int y) {
  long long result = 0;
  int id = who(x, y);
  for (int i = x; i >= 0; i = (i & (i + 1)) - 1)
    for (int j = y; j >= 0; j = (j & (j + 1)) - 1) result ^= t[i][j][id];
  return result;
}
void inc(int x, int y, long long delta) {
  int id = who(x, y);
  for (int i = x; i < N; i = (i | (i + 1)))
    for (int j = y; j < N; j = (j | (j + 1))) t[i][j][id] ^= delta;
}
void solve() {
  int n, q;
  cin >> n >> q;
  while (q--) {
    int type, x0, y0, x1, y1;
    long long val;
    cin >> type >> x0 >> y0 >> x1 >> y1;
    long long res = 0;
    if (type == 1) {
      res = sum(x1, y1);
      res ^= sum(x0 - 1, y1);
      res ^= sum(x1, y0 - 1);
      res ^= sum(x0 - 1, y0 - 1);
      cout << res << "\n";
    } else {
      cin >> val;
      inc(x0, y0, val);
      inc(x1 + 1, y0, val);
      inc(x0, y1 + 1, val);
      inc(x1 + 1, y1 + 1, val);
    }
  }
}
int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(3);
  int step = 1;
  for (int i = 0; i < step; i++) {
    solve();
  }
}
