#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 + 5;
long long s[2][2][MAXN][MAXN];
int n, m;
long long getsum(int x, int y) {
  long long res = 0;
  for (int i = x; i > 0; i ^= ((i) & -(i)))
    for (int j = y; j > 0; j ^= ((j) & -(j))) res ^= s[x & 1][y & 1][i][j];
  return res;
}
void modify(int x, int y, long long delta) {
  for (int i = x; i <= n; i += ((i) & -(i)))
    for (int j = y; j <= n; j += ((j) & -(j))) s[x & 1][y & 1][i][j] ^= delta;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, op, x1, y1, x2, y2; i <= m; i++) {
    long long delta;
    scanf("%d%d%d%d%d", &op, &x1, &y1, &x2, &y2);
    if (op == 1)
      printf("%lld\n", getsum(x2, y2) ^ getsum(x1 - 1, y2) ^
                           getsum(x2, y1 - 1) ^ getsum(x1 - 1, y1 - 1));
    if (op == 2) {
      scanf("%lld", &delta);
      modify(x1, y1, delta);
      modify(x1, y2 + 1, delta);
      modify(x2 + 1, y1, delta);
      modify(x2 + 1, y2 + 1, delta);
    }
  }
  return 0;
}
