#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);
const int MAXN = 1e3 + 5;
const int MOD = 1e9 + 7;
int sgn(double x) {
  if (fabs(x) < eps) return 0;
  if (x < 0)
    return -1;
  else
    return 1;
}
long long pw(long long a, long long n, long long mod) {
  long long ret = 1;
  while (n) {
    if (n & 1) ret = ret * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return ret;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int n, m;
long long sum[2][2][MAXN][MAXN];
int lowbit(int x) { return x & -x; }
void upd(int x, int y, long long v) {
  for (int i = x; i <= n; i += lowbit(i))
    for (int j = y; j <= n; j += lowbit(j)) sum[x & 1][y & 1][i][j] ^= v;
}
long long ask(int x, int y) {
  long long ret = 0;
  for (int i = x; i; i -= lowbit(i))
    for (int j = y; j; j -= lowbit(j)) ret ^= sum[x & 1][y & 1][i][j];
  return ret;
}
int main() {
  scanf("%d%d", &n, &m);
  int p, x1, x2, y1, y2;
  long long v, ans;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d%d%d", &p, &x1, &y1, &x2, &y2);
    if (p == 1) {
      ans =
          ask(x2, y2) ^ ask(x2, y1 - 1) ^ ask(x1 - 1, y2) ^ ask(x1 - 1, y1 - 1);
      printf("%I64d\n", ans);
    } else {
      scanf("%I64d", &v);
      upd(x1, y1, v);
      upd(x1, y2 + 1, v);
      upd(x2 + 1, y1, v);
      upd(x2 + 1, y2 + 1, v);
    }
  }
}
