#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const long long int LINF = (long long int)1e18;
long long int gcd(long long int a, long long int b) {
  long long int r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
long long int fpow(long long int n, long long int k, int p = MOD) {
  long long int r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
void addmod(long long int& a, long long int val, long long int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
void submod(long long int& a, long long int val, long long int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
int mult(long long int a, long long int b, long long int p = MOD) {
  return (long long int)a * b % p;
}
int inv(long long int a, long long int p = MOD) { return fpow(a, p - 2, p); }
int t[2][2][4004][4004];
int n, m;
int sum(int r, int c) {
  int ret = 0;
  for (int rr = r; rr; rr -= ((rr) & (-rr))) {
    for (int cc = c; cc; cc -= ((cc) & (-cc))) {
      ret ^= t[r & 1][c & 1][rr][cc];
    }
  }
  return ret;
}
void add(int r, int c, int v) {
  for (int rr = r + 1; rr < 4 * (n + 1); rr += ((rr) & (-rr))) {
    for (int cc = c + 1; cc < 4 * (n + 1); cc += ((cc) & (-cc))) {
      t[(r + 1) & 1][(c + 1) & 1][rr][cc] ^= v;
    }
  }
}
int main() {
  for (scanf("%d%d", &n, &m); m--;) {
    int op, r1, c1, r2, c2, v;
    scanf("%d%d%d%d%d", &op, &r1, &c1, &r2, &c2);
    --r1;
    --c1;
    if (op == 2) {
      scanf("%d", &v);
      add(r2, c2, v);
      add(r2, c1, v);
      add(r1, c2, v);
      add(r1, c1, v);
    }
    if (op == 1)
      printf("%d\n", sum(r2, c2) ^ sum(r1, c2) ^ sum(r2, c1) ^ sum(r1, c1));
  }
  return 0;
}
