#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
long long int bit[4][N][N];
int n;
int par(int x, int y) {
  int res = 0;
  if (x % 2) res++;
  if (y % 2) res += 2;
  return res;
}
void update(int x, int y, long long int val) {
  int y1 = y;
  int tmp = par(x, y);
  while (x <= n) {
    y1 = y;
    while (y1 <= n) {
      bit[tmp][x][y1] ^= val;
      y1 += y1 & -y1;
    }
    x += x & -x;
  }
}
long long int query(int x, int y) {
  long long int ans = 0;
  int y1 = y;
  int tmp = par(x, y);
  while (x > 0) {
    y1 = y;
    while (y1 > 0) {
      ans ^= bit[tmp][x][y1];
      y1 -= y1 & -y1;
    }
    x -= x & -x;
  }
  return ans;
}
void solve() {
  long long int m;
  cin >> n >> m;
  for (long long int i = 0; i < m; ++i) {
    int tp;
    cin >> tp;
    if (tp == 1) {
      int a, b, c, d;
      cin >> a >> b >> c >> d;
      long long int ans = query(c, d);
      ans ^= query(a - 1, d);
      ans ^= query(c, b - 1);
      ans ^= query(a - 1, b - 1);
      cout << ans << '\n';
    } else {
      int a, b, c, d;
      long long int val;
      cin >> a >> b >> c >> d;
      cin >> val;
      update(a, b, val);
      update(c + 1, b, val);
      update(a, d + 1, val);
      update(c + 1, d + 1, val);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1, tmp = 0;
  while (t--) {
    solve();
    if (t) cout << "\n";
  }
  cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
  return 0;
}
