#include <bits/stdc++.h>
using namespace std;
long long n, m, x[2], y[2], val, fen[4][1003][1003];
int check_type(int a, int b) {
  long long ans = 0;
  if (a & 1) ans++;
  if (b & 1) ans += 2;
  return ans;
}
void upd(long long x, long long y, long long val) {
  int id = check_type(x, y);
  for (long long i = x; i <= n; i += i & (-i)) {
    for (long long j = y; j <= n; j += j & (-j)) {
      fen[id][i][j] ^= val;
    }
  }
}
long long get(long long x, long long y) {
  int id = check_type(x, y), ans = 0;
  for (long long i = x; i > 0; i -= i & (-i)) {
    for (long long j = y; j > 0; j -= j & (-j)) {
      ans ^= fen[id][i][j];
    }
  }
  return ans;
}
void Solve() {
  cin >> n >> m;
  while (m--) {
    long long type;
    cin >> type;
    if (type == 2) {
      cin >> x[0] >> y[0] >> x[1] >> y[1] >> val;
      upd(x[0], y[0], val);
      upd(x[1] + 1, y[0], val);
      upd(x[0], y[1] + 1, val);
      upd(x[1] + 1, y[1] + 1, val);
    } else {
      cin >> x[0] >> y[0] >> x[1] >> y[1];
      long long res = 0;
      res = get(x[1], y[1]) ^ get(x[1], y[0] - 1) ^ get(x[0] - 1, y[1]) ^
            get(x[0] - 1, y[0] - 1);
      cout << res << "\n";
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int Test_numbers = 1;
  while (Test_numbers--) Solve();
  return 0;
}
