#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, m;
long long Tr[4][N][N];
void add(int x, int y, long long v) {
  int mask = ((x & 1) << 1) + (y & 1);
  for (int i = x; i <= n; i += i & -i)
    for (int j = y; j <= n; j += j & -j) Tr[mask][i][j] ^= v;
}
long long get(int x, int y) {
  int mask = ((x & 1) << 1) + (y & 1);
  long long res = 0;
  for (int i = x; i; i -= i & -i)
    for (int j = y; j; j -= j & -j) res ^= Tr[mask][i][j];
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int _ = 0; _ < m; _++) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      int ax, ay, bx, by;
      scanf("%d%d%d%d", &ax, &ay, &bx, &by);
      long long res = 0;
      res ^= get(bx, by);
      if (ax) res ^= get(ax - 1, by);
      if (ay) res ^= get(bx, ay - 1);
      if (ax && ay) res ^= get(ax - 1, ay - 1);
      printf("%I64d\n", res);
    } else {
      int ax, ay, bx, by;
      long long v;
      scanf("%d%d%d%d%I64d", &ax, &ay, &bx, &by, &v);
      int mask = ((ax & 1) << 1) + (ay & 1);
      add(ax, ay, v);
      add(bx + 1, ay, v);
      add(ax, by + 1, v);
      add(bx + 1, by + 1, v);
    }
  }
}
