#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = 1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f ? -x : x;
}
const long long N = 1010;
long long num[N][N][2][2], Q, n;
long long lowbit(long long x) { return x & (-x); }
void add(long long x, long long y, long long z) {
  for (long long i = x; i <= n; i += lowbit(i)) {
    for (long long j = y; j <= n; j += lowbit(j)) {
      num[i][j][x & 1][y & 1] ^= z;
    }
  }
}
long long ask(long long x, long long y) {
  long long ans = 0;
  for (long long i = x; i; i -= lowbit(i)) {
    for (long long j = y; j; j -= lowbit(j)) {
      ans ^= num[i][j][x & 1][y & 1];
    }
  }
  return ans;
}
signed main() {
  n = read();
  Q = read();
  while (Q--) {
    long long opt = read();
    if (opt == 1) {
      long long xa = read(), ya = read(), xb = read(), yb = read();
      printf("%lld\n", ask(xa - 1, ya - 1) ^ ask(xb, yb) ^ ask(xa - 1, yb) ^
                           ask(xb, ya - 1));
    }
    if (opt == 2) {
      long long xa = read(), ya = read(), xb = read(), yb = read(), d = read();
      add(xb + 1, yb + 1, d);
      add(xa, ya, d);
      add(xb + 1, ya, d);
      add(xa, yb + 1, d);
    }
  }
}
