#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
long long c[2][2][maxn][maxn];
int lowbit(int s) { return s & (-s); }
void modify(int x, int y, int v) {
  for (int i = x; i < maxn; i += lowbit(i))
    for (int j = y; j < maxn; j += lowbit(j)) c[x & 1][y & 1][i][j] ^= v;
  return;
}
long long query(int x, int y) {
  long long ret = 0;
  for (int i = x; i > 0; i -= lowbit(i))
    for (int j = y; j > 0; j -= lowbit(j)) ret ^= c[x & 1][y & 1][i][j];
  return ret;
}
int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);
  while (m--) {
    long long v;
    int op, x0, y0, x1, y1;
    scanf("%d %d %d %d %d", &op, &x0, &y0, &x1, &y1);
    if (op == 2) {
      scanf("%I64d", &v);
      modify(x0, y0, v);
      modify(x0, y1 + 1, v);
      modify(x1 + 1, y0, v);
      modify(x1 + 1, y1 + 1, v);
    } else
      printf("%I64d\n", query(x1, y1) ^ query(x0 - 1, y1) ^ query(x1, y0 - 1) ^
                            query(x0 - 1, y0 - 1));
  }
  return 0;
}
