#include <bits/stdc++.h>
using namespace std;
long long n, m, aib[2][2][1005][1005];
void up(int x, int y, long long v) {
  for (int i = x; i <= n; i += (((i) ^ (i - 1)) & (i)))
    for (int j = y; j <= n; j += (((j) ^ (j - 1)) & (j))) {
      aib[x & 1][y & 1][i][j] ^= v;
    }
}
long long sum(int x, int y) {
  long long r = 0;
  for (int i = x; 0 < i; i -= (((i) ^ (i - 1)) & (i)))
    for (int j = y; 0 < j; j -= (((j) ^ (j - 1)) & (j))) {
      r ^= aib[x & 1][y & 1][i][j];
    }
  return r;
}
int main() {
  int op, x1, y1, x2, y2;
  long long vl;
  for (cin >> n >> m; m; --m) {
    cin >> op;
    if (1 == op) {
      cin >> x1 >> y1 >> x2 >> y2;
      cout << (sum(x2, y2) ^ sum(x2, y1 - 1) ^ sum(x1 - 1, y2) ^
               sum(x1 - 1, y1 - 1))
           << '\n';
    } else {
      cin >> x1 >> y1 >> x2 >> y2 >> vl;
      up(x2 + 1, y2 + 1, vl);
      up(x2 + 1, y1, vl);
      up(x1, y2 + 1, vl);
      up(x1, y1, vl);
    }
  }
  return 0;
}
