#include <bits/stdc++.h>
using namespace std;
int n, que;
long long fen[4][(1 << 11) + 10][500 + 10];
inline long long get(int type, int root, int lo, int hi, int x, int y,
                     long long cost) {
  if (lo > x) return 0LL;
  if (hi <= x) {
    long long ret = 0;
    for (int cur = y; cur; cur -= (cur & (-cur)))
      ret ^= (fen[type][root][cur] & cost);
    return ret;
  }
  int mid = (lo + hi) / 2;
  return get(type, root * 2, lo, mid, x, y, cost) ^
         get(type, root * 2 + 1, mid + 1, hi, x, y, cost);
}
inline void go(int type, int root, int lo, int hi, int x, int y,
               long long cost) {
  if (x < lo || x > hi) return;
  for (int cur = y; cur <= n / 2 + 1; cur += (cur & (-cur)))
    fen[type][root][cur] ^= cost;
  if (lo == hi) return;
  int mid = (lo + hi) / 2;
  if (x <= mid)
    go(type, root * 2, lo, mid, x, y, cost);
  else
    go(type, root * 2 + 1, mid + 1, hi, x, y, cost);
}
inline long long _get(int x, int y) {
  return get(((x) % 2 * 2 + (y) % 2), 1, 1, n / 2 + 1, (x + 1) / 2, (y + 1) / 2,
             (1LL << 62) - 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> que;
  for (int o = 0; o < que; o++) {
    int type;
    cin >> type;
    int x, y, xx, yy;
    cin >> x >> y >> xx >> yy;
    if (type == 1) {
      long long ret = 0;
      ret +=
          _get(xx, yy) ^ _get(xx, y - 1) ^ _get(x - 1, yy) ^ _get(x - 1, y - 1);
      cout << ret << endl;
    } else {
      long long v;
      cin >> v;
      go(((x) % 2 * 2 + (y) % 2), 1, 1, n / 2 + 1, (x + 1) / 2, (y + 1) / 2, v);
      go(((xx + 1) % 2 * 2 + (y) % 2), 1, 1, n / 2 + 1, (xx + 2) / 2,
         (y + 1) / 2, v);
      go(((x) % 2 * 2 + (yy + 1) % 2), 1, 1, n / 2 + 1, (x + 1) / 2,
         (yy + 2) / 2, v);
      go(((xx + 1) % 2 * 2 + (yy + 1) % 2), 1, 1, n / 2 + 1, (xx + 2) / 2,
         (yy + 2) / 2, v);
    }
  }
  return 0;
}
