#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
const int M = 100010;
int lowbit(int x) { return x & (-x); }
long long a[4][N][N];
int n;
void Add(int x, int y, long long val) {
  if (!x || !y) return;
  for (int i = x; i <= n; i += lowbit(i)) {
    for (int j = y; j <= n; j += lowbit(j)) {
      a[0][i][j] ^= val;
      if (x % 2 == 1) a[1][i][j] ^= val;
      if (y % 2 == 1) a[2][i][j] ^= val;
      if (x % 2 && y % 2) a[3][i][j] ^= val;
    }
  }
}
long long Get(int x, int y, int op) {
  long long ans = 0;
  for (int i = x; i > 0; i -= lowbit(i)) {
    for (int j = y; j > 0; j -= lowbit(j)) {
      ans ^= a[op][i][j];
    }
  }
  return ans;
}
long long Get(int x1, int y1, int x2, int y2, int op) {
  long long ans = 0;
  ans = Get(x2, y2, op) ^ Get(x1 - 1, y1 - 1, op) ^ Get(x2, y1 - 1, op) ^
        Get(x1 - 1, y2, op);
  return ans;
}
long long Solve(int x, int y) {
  long long ans = 0;
  ans = Get(x, y, 3);
  if (y % 2) ans ^= Get(1, y + 1, x, n, 1);
  if (x % 2) ans ^= Get(x + 1, 1, n, y, 2);
  if (x % 2 && y % 2) ans ^= Get(x + 1, y + 1, n, n, 0);
  return ans;
}
int main(void) {
  int m, op, x1, y1, x2, y2;
  long long val;
  scanf("%d%d", &n, &m);
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &op);
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    if (op == 2) {
      cin >> val;
      Add(x2, y2, val);
      Add(x1 - 1, y2, val);
      Add(x2, y1 - 1, val);
      Add(x1 - 1, y1 - 1, val);
    } else {
      long long ans = Solve(x2, y2) ^ Solve(x1 - 1, y1 - 1) ^
                      Solve(x1 - 1, y2) ^ Solve(x2, y1 - 1);
      cout << ans << endl;
    }
  }
  return 0;
}
