#include <bits/stdc++.h>
using namespace std;
int n, m;
struct FenWick {
  int a[1001][1001];
  inline void add(int x, int y, int d) {
    for (int i = x; i <= n; i += ((i) & -(i)))
      for (int j = y; j <= n; j += ((j) & -(j))) a[i][j] ^= d;
  }
  inline int Sum(int x, int y) {
    int ans = 0;
    for (int i = x; i; i -= ((i) & -(i)))
      for (int j = y; j; j -= ((j) & -(j))) ans ^= a[i][j];
    return ans;
  }
};
FenWick A, B, C, D;
inline int P(int x, int y) {
  return (((x + 1) * (y + 1) & 1) * A.Sum(x, y)) ^ ((x + 1 & 1) * B.Sum(x, y)) ^
         ((y + 1 & 1) * C.Sum(x, y)) ^ (D.Sum(x, y));
}
int main() {
  int type, px, py, qx, qy, d;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &type);
    if (type == 2) {
      scanf("%d %d %d %d %d", &px, &py, &qx, &qy, &d);
      A.add(px, py, d), A.add(px, qy + 1, d), A.add(qx + 1, py, d),
          A.add(qx + 1, qy + 1, d);
      B.add(px, py, (py & 1) * d), B.add(px, qy + 1, (qy + 1 & 1) * d),
          B.add(qx + 1, py, (py & 1) * d),
          B.add(qx + 1, qy + 1, (qy + 1 & 1) * d);
      C.add(px, py, (px & 1) * d), C.add(px, qy + 1, (px & 1) * d),
          C.add(qx + 1, py, (qx + 1 & 1) * d),
          C.add(qx + 1, qy + 1, (qx + 1 & 1) * d);
      D.add(px, py, (px * py & 1) * d),
          D.add(px, qy + 1, (px * (qy + 1) & 1) * d),
          D.add(qx + 1, py, ((qx + 1) * py & 1) * d),
          D.add(qx + 1, qy + 1, ((qx + 1) * (qy + 1) & 1) * d);
    } else {
      scanf("%d %d %d %d", &px, &py, &qx, &qy);
      printf("%d\n",
             P(qx, qy) ^ P(qx, py - 1) ^ P(px - 1, qy) ^ P(px - 1, py - 1));
    }
  }
  return 0;
}
