#include <bits/stdc++.h>
using namespace std;
long long n, m;
const long long MAXN = 1010;
long long c[2][2][MAXN][MAXN];
long long lowbit(long long x) { return x & (-x); }
void add(long long a, long long b, long long val) {
  for (long long i = a; i <= n; i += lowbit(i))
    for (long long j = b; j <= n; j += lowbit(j)) c[a & 1][b & 1][i][j] ^= val;
}
long long sum(long long a, long long b) {
  long long ans = 0;
  for (long long i = a; i >= 1; i -= lowbit(i))
    for (long long j = b; j >= 1; j -= lowbit(j)) {
      ans ^= c[a & 1][b & 1][i][j];
    }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  long long x1, x2, y1, y2, val, op, ans;
  for (long long 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;
}
