#include <bits/stdc++.h>
using namespace std;
struct two_dimentional_fenwick {
  long long c[1001][1001];
  void update(long long x, long long y, long long ind) {
    for (long long i = x; i <= 1000; i += i & -i)
      for (long long j = y; j <= 1000; j += j & -j) c[i][j] ^= ind;
  }
  long long query(long long x, long long y) {
    long long ans = 0;
    for (long long i = x; i; i -= i & -i)
      for (long long j = y; j; j -= j & -j) ans ^= c[i][j];
    return ans;
  }
} f[4];
long long parity(long long x, long long y) {
  if (x % 2 == 1 && y % 2 == 1) return 0;
  if (x % 2 == 0 && y % 2 == 1) return 1;
  if (x % 2 == 1 && y % 2 == 0) return 2;
  if (x % 2 == 0 && y % 2 == 0) return 3;
}
void change(long long x, long long y, long long ind) {
  f[parity(x, y)].update(x, y, ind);
}
long long ask(long long x, long long y) { return f[parity(x, y)].query(x, y); }
char s[100001];
signed main() {
  long long n, T;
  scanf("%lld%lld", &n, &T);
  while (T--) {
    long long op;
    scanf("%lld", &op);
    if (op == 1) {
      long long x, y, xx, yy;
      scanf("%lld%lld%lld%lld", &x, &y, &xx, &yy);
      long long ans = 0;
      ans ^= ask(xx, yy);
      ans ^= ask(x - 1, yy);
      ans ^= ask(xx, y - 1);
      ans ^= ask(x - 1, y - 1);
      printf("%d\n", ans);
    } else {
      long long x, y, xx, yy, ind;
      scanf("%lld%lld%lld%lld%lld", &x, &y, &xx, &yy, &ind);
      change(x, y, ind);
      change(xx + 1, y, ind);
      change(x, yy + 1, ind);
      change(xx + 1, yy + 1, ind);
    }
  }
  return 0;
}
