#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 1;
const int INF = 1e9 + 9;
const int B = 1e9 + 7;
struct Fenwick2d {
  int n;
  long long t[N][N];
  void init(int _n) { n = _n; }
  void upd(int r, int c, long long delta) {
    for (int i = r; i <= n; i |= i + 1)
      for (int j = c; j <= n; j |= j + 1) t[i][j] ^= delta;
  }
  long long get(int r, int c) {
    long long ans = 0;
    for (int i = r; i >= 1; i = (i & (i + 1)) - 1)
      for (int j = c; j >= 1; j = (j & (j + 1)) - 1) ans ^= t[i][j];
    return ans;
  }
} tree[2][2];
int n, q;
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (int i = int(0); i <= int(1); ++i)
    for (int j = int(0); j <= int(1); ++j) tree[i][j].init(n);
  for (int i = int(1); i <= int(q); ++i) {
    int tp, r1, c1, r2, c2;
    cin >> tp >> r1 >> c1 >> r2 >> c2;
    if (tp == 1) {
      long long ans = 0;
      ans ^= tree[r2 & 1][c2 & 1].get(r2, c2);
      ans ^= tree[r2 & 1][(c1 & 1) ^ 1].get(r2, c1 - 1);
      ans ^= tree[(r1 & 1) ^ 1][c2 & 1].get(r1 - 1, c2);
      ans ^= tree[(r1 & 1) ^ 1][(c1 & 1) ^ 1].get(r1 - 1, c1 - 1);
      cout << ans << "\n";
    } else {
      long long x;
      cin >> x;
      tree[r1 & 1][c1 & 1].upd(r1, c1, x);
      tree[r1 & 1][(c2 & 1) ^ 1].upd(r1, c2 + 1, x);
      tree[(r2 & 1) ^ 1][c1 & 1].upd(r2 + 1, c1, x);
      tree[(r2 & 1) ^ 1][(c2 & 1) ^ 1].upd(r2 + 1, c2 + 1, x);
    }
  }
  return 0;
}
