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