#include <bits/stdc++.h>
using namespace std;
int n, m;
const int MAXN = 1010;
long long c[2][2][MAXN][MAXN];
void add(int a, int b, long long val) {
  int aa = a & 1, bb = b & 1;
  for (int i = a; i <= n; i += (i & (-i)))
    for (int j = b; j <= n; j += (j & (-j))) c[aa][bb][i][j] ^= val;
}
long long sum(int a, int b) {
  int aa = a & 1, bb = b & 1;
  long long ans = 0;
  for (int i = a; i >= 1; i -= (i & (-i)))
    for (int j = b; j >= 1; j -= (j & (-j))) {
      ans ^= c[aa & 1][bb & 1][i][j];
    }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  int x1, x2, y1, y2, op;
  long long val;
  long long ans;
  for (int i = 1; i <= m; i++) {
    cin >> op;
    if (op == 1) {
      cin >> x1 >> y1 >> x2 >> y2;
      ans =
          sum(x2, y2) ^ sum(x2, y1 - 1) ^ sum(x1 - 1, y2) ^ sum(x1 - 1, y1 - 1);
      cout << ans << endl;
    } else {
      cin >> x1 >> y1 >> x2 >> y2 >> val;
      add(x1, y1, val), add(x2 + 1, y1, val), add(x1, y2 + 1, val),
          add(x2 + 1, y2 + 1, val);
    }
  }
  return 0;
}
