#include <bits/stdc++.h>
using namespace std;
const int NR = 1010;
int n, m;
int d[2][2][NR][NR];
long long lowbit(long long x) { return x & (-x); }
int Sum(int x, int y) {
  int res = 0;
  for (int i = x; i; i -= lowbit(i))
    for (int j = y; j; j -= lowbit(j)) res ^= d[x & 1][y & 1][i][j];
  return res;
}
void add(int x, int y, int k) {
  for (int i = x; i <= n; i += lowbit(i))
    for (int j = y; j <= n; j += lowbit(j)) d[x & 1][y & 1][i][j] ^= k;
}
int main() {
  scanf("%d%d", &n, &m);
  int opt;
  for (int j = 1; j <= m; j++) {
    scanf("%d", &opt);
    if (opt == 1) {
      int x1, x2, y1, y2;
      scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
      printf("%d\n", Sum(x2, y2) ^ Sum(x1 - 1, y2) ^ Sum(x2, y1 - 1) ^
                         Sum(x1 - 1, y1 - 1));
    }
    if (opt == 2) {
      int x1, x2, y1, y2, k;
      scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &k);
      add(x1, y1, k);
      add(x2 + 1, y1, k);
      add(x1, y2 + 1, k);
      add(x2 + 1, y2 + 1, k);
    }
  }
  return 0;
}
