#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
const int M = 100010;
long long _ll[N][N], lr[N][N], rl[N][N], rr[N][N];
int n, m;
void insert(long long bit[][N], int x, int y, long long c) {
  if (x == 0 || y == 0) return;
  for (int i = x; i < N; i += i & (-i))
    for (int j = y; j < N; j += j & (-j)) bit[i][j] ^= c;
}
long long query(long long bit[][N], int x, int y) {
  if (x == 0 || y == 0) return 0;
  long long ret = 0;
  for (int i = x; i; i -= i & (-i))
    for (int j = y; j; j -= j & (-j)) ret ^= bit[i][j];
  return ret;
}
void insert(int x, int y, long long c) {
  if ((x * y) & 1) insert(_ll, x, y, c);
  if (1) insert(rr, x, y, c);
  if (x & 1) insert(lr, x, y, c);
  if (y & 1) insert(rl, x, y, c);
}
long long query(int x, int y) {
  long long ret = 0;
  ret ^= query(_ll, x, y);
  if ((x * y) & 1)
    ret ^=
        query(rr, n, n) ^ query(rr, x, n) ^ query(rr, n, y) ^ query(rr, x, y);
  if (x & 1) ret ^= query(rl, n, y) ^ query(rl, x, y);
  if (y & 1) ret ^= query(lr, x, n) ^ query(lr, x, y);
  return ret;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int t, a, b, c, d;
    cin >> t >> a >> b >> c >> d;
    if (t == 1) {
      long long ans = 0;
      ans ^= query(c, d);
      ans ^= query(a - 1, b - 1);
      ans ^= query(c, b - 1);
      ans ^= query(a - 1, d);
      cout << ans << endl;
    } else {
      long long e;
      cin >> e;
      insert(c, d, e);
      insert(a - 1, b - 1, e);
      insert(a - 1, d, e);
      insert(c, b - 1, e);
    }
  }
}
