#include <bits/stdc++.h>
using namespace std;
long long n, m;
struct szsz {
  long long c[1005][1005];
  void gai(long long x, long long y, long long v) {
    long long yy = y;
    for (long long i = x; i <= n; i += (i & (-i)))
      for (long long j = y; j <= n; j += (j & (-j))) c[i][j] ^= v;
  }
  long long he(long long x, long long y) {
    long long ans = 0;
    for (long long i = x; i > 0; i -= (i & (-i)))
      for (long long j = y; j > 0; j -= (j & (-j))) {
        ans ^= c[i][j];
      }
    return ans;
  }
} c[5];
long long QAQ(long long x, long long y) {
  long long rt = 0;
  if (x & 1) rt += 1;
  if (y & 1) rt += 2;
  return rt;
}
signed main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= m; i++) {
    long long opt, ax, ay, bx, by, v;
    scanf("%lld", &opt);
    if (opt == 1) {
      scanf("%lld%lld%lld%lld", &ax, &ay, &bx, &by);
      long long ans = c[QAQ(bx, by)].he(bx, by);
      ans ^= c[QAQ(bx, ay - 1)].he(bx, ay - 1);
      ans ^= c[QAQ(ax - 1, by)].he(ax - 1, by);
      ans ^= c[QAQ(ax - 1, ay - 1)].he(ax - 1, ay - 1);
      printf("%lld\n", ans);
    } else {
      scanf("%lld%lld%lld%lld%lld", &ax, &ay, &bx, &by, &v);
      c[QAQ(ax, ay)].gai(ax, ay, v);
      c[QAQ(bx + 1, ay)].gai(bx + 1, ay, v);
      c[QAQ(ax, by + 1)].gai(ax, by + 1, v);
      c[QAQ(bx + 1, by + 1)].gai(bx + 1, by + 1, v);
    }
  }
  return 0;
}
