#include <bits/stdc++.h>
using namespace std;
const int N = 1100;
int n, m;
long long aib[5][N][N];
inline int getPoz(int x, int y) {
  if ((x & 1) && (y & 1)) return 1;
  if ((x & 1)) return 2;
  if ((y & 1)) return 3;
  return 4;
}
inline long long query(int x, int y) {
  int poz = getPoz(x, y);
  long long r = 0;
  for (; x > 0; x -= (x & (-x)))
    for (int j = y; j > 0; j -= (j & (-j))) r ^= aib[poz][x][j];
  return r;
}
inline void update(int x, int y, int val) {
  int poz = getPoz(x, y);
  for (; x <= n; x += (x & (-x)))
    for (int j = y; j <= n; j += (j & (-j))) aib[poz][x][j] ^= val;
}
int main() {
  int i;
  cin >> n >> m;
  for (i = 1; i <= m; ++i) {
    int op, x1, x2, y1, y2;
    long long val;
    cin >> op >> x1 >> y1 >> x2 >> y2;
    if (op == 1) {
      cout << (query(x2, y2) ^ query(x2, y1 - 1) ^ query(x1 - 1, y2) ^
               query(x1 - 1, y1 - 1))
           << "\n";
    } else {
      cin >> val;
      update(x1, y1, val);
      update(x1, y2 + 1, val);
      update(x2 + 1, y1, val);
      update(x2 + 1, y2 + 1, val);
    }
  }
  return 0;
}
