#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
using namespace std;
const double eps = 1e-6;
const long long mod = 1e9 + 7;
const int maxn = 2e5 + 100;
const int maxe = 1e6 + 100;
long long v;
int n, m, op;
long long c[2][2][1010][1010];
void add(int a, int b) {
  for (int i = a; i <= n; i += (i & (-i))) {
    for (int j = b; j <= n; j += (j & (-j))) {
      c[a & 1][b & 1][i][j] ^= v;
    }
  }
}
long long sum(int a, int b) {
  long long ans = 0;
  for (int i = a; i >= 1; i -= (i & (-i))) {
    for (int j = b; j >= 1; j -= (j & (-j))) {
      ans ^= c[a & 1][b & 1][i][j];
    }
  }
  return ans;
}
void Solve() {
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(c, 0, sizeof(c));
    for (int i = 0; i < m; i++) {
      int x1, y1, x2, y2;
      scanf("%d%d%d%d%d", &op, &x1, &y1, &x2, &y2);
      if (op == 2) {
        scanf("%I64d", &v);
        add(x1, y1);
        add(x2 + 1, y2 + 1);
        add(x1, y2 + 1);
        add(x2 + 1, y1);
      }
      if (op == 1) {
        printf("%I64d\n", sum(x2, y2) ^ sum(x2, y1 - 1) ^ sum(x1 - 1, y2) ^
                              sum(x1 - 1, y1 - 1));
      }
    }
  }
  return;
}
int main() {
  int Case = 1, cases;
  while (Case--) {
    Solve();
  }
  return 0;
}
