#include <bits/stdc++.h>
using namespace std;
long long n, N, m, op, w, ax, ay, bx, by, cx, cy, ix, iy, bit[4][505][505];
long long v(long long x) {
  if (x & 1)
    return (x >> 1) + 1;
  else
    return x >> 1;
}
long long P(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;
}
long long lowbit(long long x) { return x & (-x); }
void add(long long x, long long y, long long w) {
  long long i, j, k = P(x, y);
  ix = v(x);
  iy = v(y);
  for (i = ix; i <= N; i += lowbit(i))
    for (j = iy; j <= N; j += lowbit(j)) bit[k][i][j] ^= w;
}
long long get(long long x, long long y) {
  if (x == 0 || y == 0) return 0;
  long long i, j, k = P(x, y), ret = 0;
  ix = v(x);
  iy = v(y);
  for (i = ix; i; i -= lowbit(i))
    for (j = iy; j; j -= lowbit(j)) ret ^= bit[k][i][j];
  return ret;
}
signed main() {
  long long i, j;
  scanf("%lld%lld", &n, &m);
  N = v(n);
  while (m--) {
    scanf("%lld%lld%lld%lld%lld", &op, &ax, &ay, &bx, &by);
    if (op == 1)
      printf("%lld\n", get(bx, by) ^ get(ax - 1, by) ^ get(bx, ay - 1) ^
                           get(ax - 1, ay - 1));
    else {
      scanf("%lld", &w);
      add(ax, ay, w);
      add(bx + 1, ay, w);
      add(ax, by + 1, w);
      add(bx + 1, by + 1, w);
    }
  }
  return 0;
}
