#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
struct ft_t {
  long long d[N], t[N];
  void init() {
    memset(d, 0, sizeof(d));
    memset(t, 0, sizeof(t));
  }
  void put(long long x, long long k) {
    for (int i = x + 1; i < N; i += -i & i) d[i] ^= k;
    for (int i = x + 1; (x & 1) && i < N; i += -i & i) t[i] ^= k;
  }
  long long ask(long long x, long long lrv = 0, long long rrv = 0) {
    for (int i = x + 1; i; i -= -i & i) lrv ^= d[i];
    for (int i = x + 1; i; i -= -i & i) rrv ^= t[i];
    return (x + 1 & 1) * lrv ^ rrv;
  }
};
struct ft2_t {
  ft_t d[N], t[N];
  void init() {
    for (int i = 0; i < N; i++) {
      d[i].init();
      t[i].init();
    }
  }
  void put(long long x, long long y, long long k) {
    for (int i = x + 1; i < N; i += -i & i) d[i].put(y, k);
    for (int i = x + 1; (x & 1) && i < N; i += -i & i) t[i].put(y, k);
  }
  long long ask(long long x, long long y, long long lrv = 0,
                long long rrv = 0) {
    for (int i = x + 1; i; i -= -i & i) lrv ^= d[i].ask(y);
    for (int i = x + 1; i; i -= -i & i) rrv ^= t[i].ask(y);
    return (x + 1 & 1) * lrv ^ rrv;
  }
  void draw(long long x0, long long y0, long long x1, long long y1,
            long long k) {
    put(x0, y0, k), put(x1 + 1, y0, k), put(x0, y1 + 1, k),
        put(x1 + 1, y1 + 1, k);
  }
  long long pick(long long x0, long long y0, long long x1, long long y1) {
    return ask(x1, y1) ^ ask(x0 - 1, y1) ^ ask(x1, y0 - 1) ^
           ask(x0 - 1, y0 - 1);
  }
};
int n, m;
ft2_t zkl;
int main() {
  for (; ~scanf("%d%d", &n, &m);) {
    zkl.init();
    for (int op, x0, y0, x1, y1; m--;) {
      scanf("%d%d%d%d%d", &op, &x0, &y0, &x1, &y1);
      if (op == 1) {
        cout << zkl.pick(x0, y0, x1, y1) << endl;
      } else {
        long long k;
        scanf("%lld", &k);
        zkl.draw(x0, y0, x1, y1, k);
      }
    }
  }
  return 0;
}
