#include <bits/stdc++.h>
using namespace std;
using lli = long long;
using lld = long double;
using ulli = unsigned long long int;
using pll = pair<lli, lli>;
using ttt = pair<lli, pll>;
using vttt = vector<ttt>;
using vll = vector<pll>;
using vl = vector<lli>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using cd = complex<lld>;
const double PI = acos(-1);
lli fen[2][2][1005][1005];
lli query(int x, int y) {
  lli res = 0;
  int px = x % 2, py = y % 2;
  for (int i = x + 2; i > 0; i -= (i & -i))
    for (int j = y + 2; j > 0; j -= (j & -j)) res ^= fen[px][py][i][j];
  return res;
}
void update(int x, int y, long long val) {
  int px = x % 2, py = y % 2;
  for (int i = x + 2; i < 1005; i += (i & -i))
    for (int j = y + 2; j < 1005; j += (j & -j)) fen[px][py][i][j] ^= val;
}
int tejas_919(int kkkk) {
  lli n, m, k, q, u, v, temp = 0, ans = 0;
  cin >> n >> q;
  while (q--) {
    lli typ, x0, x1, y0, y1, val = 0;
    cin >> typ >> x0 >> y0 >> x1 >> y1;
    if (typ == 1) {
      x0--;
      y0--;
      val ^= query(x1, y1);
      val ^= query(x0, y1);
      val ^= query(x1, y0);
      val ^= query(x0, y0);
      cout << val << '\n';
    } else {
      cin >> val;
      x1++;
      y1++;
      update(x0, y0, val);
      update(x0, y1, val);
      update(x1, y0, val);
      update(x1, y1, val);
    }
  }
  return 0;
}
signed main() {
  if (!0) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  }
  cout << fixed << setprecision(10);
  int t = 1;
  for (int i = 0; i < t; i++) {
    tejas_919(i + 1);
  }
  {};
}
