#include <bits/stdc++.h>
using namespace std;
int n = 0, m = 0;
long long c[2][2][1002][1002] = {0};
int lowbit(int x);
void add(int px, int py, long long v);
long long query(int px, int py);
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, p = 0, x1 = 0, y1 = 0, x2 = 0, y2 = 0; i <= m; ++i) {
    scanf("%d%d%d%d%d", &p, &x1, &y1, &x2, &y2);
    if (p == 1) {
      printf("%I64d\n", query(x2, y2) ^ query(x1 - 1, y2) ^ query(x2, y1 - 1) ^
                            query(x1 - 1, y1 - 1));
    } else {
      long long v = 0;
      scanf("%lld", &v);
      add(x1, y1, v);
      add(x1, y2 + 1, v);
      add(x2 + 1, y1, v);
      add(x2 + 1, y2 + 1, v);
    }
  }
}
long long query(int px, int py) {
  long long ret = 0;
  for (int i = px; i >= 1; i -= lowbit(i))
    for (int j = py; j >= 1; j -= lowbit(j)) ret ^= c[px & 1][py & 1][i][j];
  return ret;
}
void add(int px, int py, long long v) {
  for (int i = px; i <= n; i += lowbit(i))
    for (int j = py; j <= n; j += lowbit(j)) c[px & 1][py & 1][i][j] ^= v;
}
int lowbit(int x) { return x & -x; }
