#include <bits/stdc++.h>
using namespace std;
int n, m;
long long bit[4][1005][1005];
int parity(int x, int y) {
  int res = 0;
  if (x % 2) res += 1;
  if (y % 2) res += 2;
  return res;
}
void update(int x, int y, long long val) {
  int y1;
  int a = parity(x, y);
  while (x <= n) {
    y1 = y;
    while (y1 <= n) {
      bit[a][x][y1] ^= val;
      y1 += (y1 & -y1);
    }
    x += (x & -x);
  }
}
long long read(int x, int y) {
  long long sum = 0;
  int a = parity(x, y);
  while (x) {
    int y1 = y;
    while (y1) {
      sum ^= bit[a][x][y1];
      y1 -= (y1 & -y1);
    }
    x -= x & -x;
  }
  return sum;
}
int main() {
  int i, type, x1, x2, y1, y2;
  scanf("%d", &n), scanf("%d", &m);
  long long v;
  for (i = 0; i < m; i++) {
    scanf("%d", &type), scanf("%d", &x1), scanf("%d", &y1), scanf("%d", &x2),
        scanf("%d", &y2);
    if (type == 2) {
      scanf("%I64d", &v);
      update(x2 + 1, y2 + 1, v);
      update(x1, y1, v);
      update(x1, y2 + 1, v);
      update(x2 + 1, y1, v);
    } else {
      printf("%I64d\n", read(x2, y2) ^ read(x1 - 1, y1 - 1) ^ read(x1 - 1, y2) ^
                            read(x2, y1 - 1));
    }
  }
  return 0;
}
