#include <bits/stdc++.h>
using namespace std;
long long tr[2][2][1100][1100];
long long n, q;
inline long long lowbit(long long x) { return x & (-x); }
void upd(long long x, long long y, long long v) {
  long long a = x & 1, b = y & 1;
  for (long long i = x; i <= n; i += lowbit(i)) {
    for (long long j = y; j <= n; j += lowbit(j)) {
      tr[a][b][i][j] ^= v;
    }
  }
}
long long qry(long long x, long long y) {
  long long ans = 0;
  long long a = x & 1, b = y & 1;
  for (long long i = x; i >= 1; i -= lowbit(i)) {
    for (long long j = y; j >= 1; j -= lowbit(j)) {
      ans ^= tr[a][b][i][j];
    }
  }
  return ans;
}
void rectupd(long long u, long long d, long long l, long long r, long long v) {
  upd(u, l, v);
  upd(u, r + 1, v);
  upd(d + 1, l, v);
  upd(d + 1, r + 1, v);
}
long long rectqry(long long u, long long d, long long l, long long r) {
  long long ans = 0;
  ans ^= qry(d, r);
  ans ^= qry(d, l - 1);
  ans ^= qry(u - 1, r);
  ans ^= qry(u - 1, l - 1);
  return ans;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (long long _ = 1; _ <= q; _++) {
    long long ty, u, d, l, r;
    cin >> ty >> u >> l >> d >> r;
    if (ty == 1) {
      cout << rectqry(u, d, l, r) << '\n';
    }
    if (ty == 2) {
      long long v;
      cin >> v;
      rectupd(u, d, l, r, v);
    }
  }
}
