#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000,100000000000")
using namespace std;
const long long inf = 1e18 + 7;
const long long mod = 1e9 + 7;
const double eps = 1e-12;
const double PI = 2 * acos(0.0);
const double E = 2.71828;
int n, q;
long long t[4][1005][1005];
int get_mask(int x, int y) {
  int ret = 0;
  if (x & 1) ret |= 1;
  if (y & 1) ret |= 2;
  return ret;
}
void update(int x, int y, long long val) {
  int mask = get_mask(x, y);
  for (int i = x; i <= n; i += i & -i)
    for (int j = y; j <= n; j += j & -j) t[mask][i][j] ^= val;
}
int get(int x, int y) {
  int mask = get_mask(x, y);
  int res = 0;
  for (int i = x; i; i -= i & -i)
    for (int j = y; j; j -= j & -j) res ^= t[mask][i][j];
  return res;
}
int main(void) {
  scanf("%d%d", &n, &q);
  for (int(i) = 0; (i) < (long long)(q); (i)++) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int x0, y0, x1, y1;
      scanf("%d%d%d%d", &x0, &y0, &x1, &y1);
      long long res = get(x1, y1);
      res ^= get(x0 - 1, y1);
      res ^= get(x1, y0 - 1);
      res ^= get(x0 - 1, y0 - 1);
      printf("%I64d\n", res);
    } else {
      int x0, y0, x1, y1;
      long long val;
      scanf("%d%d%d%d%I64d", &x0, &y0, &x1, &y1, &val);
      update(x0, y0, val);
      update(x0, y1 + 1, val);
      update(x1 + 1, y0, val);
      update(x1 + 1, y1 + 1, val);
    }
  }
  return 0;
}
