#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int n, m, z[2][2][N][N];
void upd(int x, int y, long long v) {
  for (int a = x; a <= n; a += ((a) & (-(a))))
    for (int b = y; b <= n; b += ((b) & (-(b)))) z[x & 1][y & 1][a][b] ^= v;
}
long long qry(int x, int y) {
  long long ans = 0;
  for (int a = x; a; a -= ((a) & (-(a))))
    for (int b = y; b; b -= ((b) & (-(b)))) ans ^= z[x & 1][y & 1][a][b];
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int a = 1; a <= m; a++) {
    int op, x1, y1, x2, y2;
    scanf("%d%d%d%d%d", &op, &x1, &y1, &x2, &y2);
    if (op == 1)
      printf("%I64d\n", qry(x1 - 1, y1 - 1) ^ qry(x2, y1 - 1) ^
                            qry(x1 - 1, y2) ^ qry(x2, y2));
    else {
      long long v;
      scanf("%I64d", &v);
      upd(x1, y1, v), upd(x2 + 1, y1, v), upd(x1, y2 + 1, v),
          upd(x2 + 1, y2 + 1, v);
    }
  }
  return 0;
}
