#include <bits/stdc++.h>
using namespace std;
long long tree[2][2][1200][1200];
int n, m;
int add(int x, int y, int v) {
  for (int i = x; i <= n; i += i & (-i))
    for (int j = y; j <= n; j += j & (-j)) tree[x & 1][y & 1][i][j] ^= v;
  return 0;
}
long long sum(int x, int y) {
  long long ans = 0;
  for (int i = x; i > 0; i -= i & (-i))
    for (int j = y; j > 0; j -= j & (-j)) ans ^= tree[x & 1][y & 1][i][j];
  return ans;
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= m; i++) {
      int op;
      scanf("%d", &op);
      int x1, y1, x2, y2;
      scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
      if (op == 2) {
        long long val;
        cin >> val;
        add(x2 + 1, y2 + 1, val);
        add(x1, y2 + 1, val);
        add(x2 + 1, y1, val);
        add(x1, y1, val);
      } else {
        long long ans = 0;
        ans ^= sum(x2, y2);
        if (x1 > 1) ans ^= sum(x1 - 1, y2);
        if (y1 > 1) ans ^= sum(x2, y1 - 1);
        if (x1 > 1 && y1 > 1) ans ^= sum(x1 - 1, y1 - 1);
        cout << ans << endl;
      }
    }
  }
  return 0;
}
