#include <bits/stdc++.h>
using namespace std;
int n, m;
long long a[2][1001][2][1001], v;
inline long long f(int x, int y) {
  long long r = 0;
  for (int i = y; i >= 1; i ^= i & -i)
    for (int j = x; j >= 1; j ^= j & -j) r ^= a[y & 1][i][x & 1][j];
  return r;
}
inline void g(int x, int y) {
  for (int i = y; i <= n; i += i & -i)
    for (int j = x; j <= n; j += j & -j) a[y & 1][i][x & 1][j] ^= v;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  while (m--) {
    int t, x0, y0, x1, y1;
    cin >> t >> x0 >> y0 >> x1 >> y1;
    if (t == 1) {
      cout << (f(x1, y1) ^ f(x0 - 1, y0 - 1) ^ f(x1, y0 - 1) ^ f(x0 - 1, y1))
           << endl;
    } else {
      cin >> v;
      g(x0, y0), g(x1 + 1, y0), g(x0, y1 + 1), g(x1 + 1, y1 + 1);
    }
  }
}
