#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
long long a[N][N];
long long ax[N][N];
long long ay[N][N];
long long axy[N][N];
void Updata(long long a[N][N], int x, int y, int n, int m, int data) {
  for (; x <= n; x += (x & (-x)))
    for (int t = y; t <= m; t += (t & (-t))) a[x][t] ^= data;
}
long long Query(long long a[N][N], int x, int y) {
  long long sum = 0;
  while (x > 0) {
    for (int t = y; t > 0; t -= (t & (-t))) sum ^= a[x][t];
    x -= (x & (-x));
  }
  return sum;
}
long long sum(int x, int y) {
  return Query(a, x, y) * ((x + 1) * (y + 1) & 1) ^
         ((y + 1) & 1) * Query(ax, x, y) ^ ((x + 1) & 1) * Query(ay, x, y) ^
         Query(axy, x, y);
}
void Add(int x1, int y1, int x2, int y2, int n, int m, long long data) {
  Updata(a, x1, y1, n, m, data);
  Updata(a, x2 + 1, y1, n, m, data);
  Updata(a, x1, y2 + 1, n, m, data);
  Updata(a, x2 + 1, y2 + 1, n, m, data);
  Updata(ax, x1, y1, n, m, x1 % 2 * data);
  Updata(ax, x2 + 1, y1, n, m, (x2 + 1) % 2 * data);
  Updata(ax, x1, y2 + 1, n, m, x1 % 2 * data);
  Updata(ax, x2 + 1, y2 + 1, n, m, (x2 + 1) % 2 * data);
  Updata(ay, x1, y1, n, m, y1 % 2 * data);
  Updata(ay, x2 + 1, y1, n, m, y1 % 2 * data);
  Updata(ay, x1, y2 + 1, n, m, (y2 + 1) % 2 * data);
  Updata(ay, x2 + 1, y2 + 1, n, m, (y2 + 1) % 2 * data);
  Updata(axy, x1, y1, n, m, x1 * y1 % 2 * data);
  Updata(axy, x2 + 1, y1, n, m, (x2 + 1) * y1 % 2 * data);
  Updata(axy, x1, y2 + 1, n, m, x1 * (y2 + 1) % 2 * data);
  Updata(axy, x2 + 1, y2 + 1, n, m, (x2 + 1) * (y2 + 1) % 2 * data);
}
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    while (m--) {
      int op, x1, y1, x2, y2;
      long long data;
      scanf("%d", &op);
      if (op == 2) {
        scanf("%d%d%d%d%I64d", &x1, &y1, &x2, &y2, &data);
        Add(x1, y1, x2, y2, n, n, data);
      } else {
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        printf("%I64d\n", sum(x2, y2) ^ sum(x1 - 1, y2) ^ sum(x2, y1 - 1) ^
                              sum(x1 - 1, y1 - 1));
      }
    }
  }
  return 0;
}
