#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
long long n, m, c[4][1005][1005];
inline long long f(long long x, long long y) {
  if ((x & 1) && (y & 1)) return 0;
  if (!(x & 1) && (y & 1)) return 1;
  if ((x & 1) && !(y & 1)) return 2;
  if (!(x & 1) && !(y & 1)) return 3;
}
inline long long lowbit(long long x) { return x & (-x); }
inline void modify(long long x, long long y, long long d) {
  long long F = f(x, y);
  for (long long i = x; i <= n; i += lowbit(i))
    for (long long j = y; j <= n; j += lowbit(j)) c[F][i][j] ^= d;
}
inline long long getsum(long long x, long long y) {
  long long sum = 0, F = f(x, y);
  for (long long i = x; i; i ^= lowbit(i))
    for (long long j = y; j; j ^= lowbit(j)) sum ^= c[F][i][j];
  return sum;
}
inline long long query(long long x, long long y, long long xx, long long yy) {
  return getsum(xx, yy) ^ getsum(x - 1, yy) ^ getsum(xx, y - 1) ^
         getsum(x - 1, y - 1);
}
inline void add(long long x, long long y, long long xx, long long yy,
                long long d) {
  modify(x, y, d);
  modify(xx + 1, y, d);
  modify(x, yy + 1, d);
  modify(xx + 1, yy + 1, d);
}
signed main() {
  n = read();
  m = read();
  long long p, x, y, xx, yy, d;
  while (m--) {
    p = read();
    x = read();
    y = read();
    xx = read();
    yy = read();
    if (p == 1)
      printf("%lld\n", query(x, y, xx, yy));
    else
      d = read(), add(x, y, xx, yy, d);
  }
  return 0;
}
