#include <bits/stdc++.h>
long long c1[1060][1060], c2[1060][1060], c3[1060][1060], c4[1060][1060];
void modify(int x, int y, long long z) {
  for (int i = x; i < 1060; i += i & -i)
    for (int j = y; j < 1060; j += j & -j) {
      c1[i][j] ^= z;
      c2[i][j] ^= (x & 1) ? z : 0;
      c3[i][j] ^= (y & 1) ? z : 0;
      c4[i][j] ^= ((x * y) & 1) ? z : 0;
    }
}
void add(int x1, int y1234, int x2, int y2, long long x) {
  x2++;
  y2++;
  modify(x2, y2, x);
  modify(x1, y2, x);
  modify(x2, y1234, x);
  modify(x1, y1234, x);
}
long long query(int x, int y) {
  long long ans(0);
  for (int i = x; i; i -= i & (-i))
    for (int j = y; j; j -= j & (-j)) {
      ans ^= ((x & 1) || (y & 1)) ? 0 : c1[i][j];
      ans ^= (y & 1) ? 0 : c2[i][j];
      ans ^= (x & 1) ? 0 : c3[i][j];
      ans ^= c4[i][j];
    }
  return ans;
}
long long ask(int x1, int y1234, int x2, int y2) {
  x1--;
  y1234--;
  return query(x2, y2) ^ query(x1, y2) ^ query(x2, y1234) ^ query(x1, y1234);
}
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      int x1, y1234, x2, y2;
      scanf("%d%d%d%d", &x1, &y1234, &x2, &y2);
      printf("%lld\n", ask(x1, y1234, x2, y2));
    } else {
      int x1, y1234, x2, y2, d;
      scanf("%d%d%d%d%d", &x1, &y1234, &x2, &y2, &d);
      add(x1, y1234, x2, y2, d);
    }
  }
}
