#include <bits/stdc++.h>
long long tree[2][2][1005][1005];
int n, m;
void update(int x, int y, long long val) {
  for (int i = x; i <= n; i += (i & -i))
    for (int j = y; j <= n; j += (j & -j)) tree[x & 1][y & 1][i][j] ^= val;
}
long long find(int x, int y) {
  long long ret = 0;
  for (int i = x; i > 0; i -= (i & -i))
    for (int j = y; j > 0; j -= (j & -j)) ret ^= tree[x & 1][y & 1][i][j];
  return ret;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int op, x1, y1, x2, y2;
    scanf("%d%d%d%d%d", &op, &x1, &y1, &x2, &y2);
    if (op == 1) {
      long long ans = find(x2, y2) ^ find(x1 - 1, y2) ^ find(x2, y1 - 1) ^
                      find(x1 - 1, y1 - 1);
      printf("%I64d\n", ans);
    } else {
      long long val;
      scanf("%I64d", &val);
      update(x1, y1, val);
      update(x2 + 1, y1, val);
      update(x1, y2 + 1, val);
      update(x2 + 1, y2 + 1, val);
    }
  }
}
