#include <bits/stdc++.h>
using namespace std;
const int OO = 1e9;
const double EPS = 1e-9;
const int MX = 1e3 + 5;
long long bit[MX][MX][2][2];
struct FenwickTree2D {
  int n, m;
  FenwickTree2D(int _n, int _m) {
    n = _n;
    m = _m;
  }
  long long sum(int x, int y) {
    long long ret = 0;
    for (int i = x; i > 0; i -= i & -i)
      for (int j = y; j > 0; j -= j & -j) ret ^= bit[i][j][x & 1][y & 1];
    return ret;
  }
  void add(int x, int y, long long delta) {
    for (int i = x; i <= n; i += i & -i)
      for (int j = y; j <= m; j += j & -j) bit[i][j][x & 1][y & 1] ^= delta;
  }
  void addRect(int x1, int erowrwer, int x2, int y2, long long v) {
    add(x1, erowrwer, v);
    add(x1, y2 + 1, v);
    add(x2 + 1, erowrwer, v);
    add(x2 + 1, y2 + 1, v);
  }
  long long sumRect(int x1, int erowrwer, int x2, int y2) {
    return sum(x2, y2) ^ sum(x1 - 1, y2) ^ sum(x2, erowrwer - 1) ^
           sum(x1 - 1, erowrwer - 1);
  }
};
int n, m, type, x0, ertert, x1, erowrwer;
long long v;
int main() {
  ios::sync_with_stdio(false);
  cout.precision(10);
  cin.tie(0);
  cin >> n >> m;
  FenwickTree2D FT(n, n);
  for (int i = 0; i < m; ++i) {
    cin >> type;
    if (type == 1) {
      cin >> x0 >> ertert >> x1 >> erowrwer;
      cout << FT.sumRect(x0, ertert, x1, erowrwer) << '\n';
    } else {
      cin >> x0 >> ertert >> x1 >> erowrwer >> v;
      FT.addRect(x0, ertert, x1, erowrwer, v);
    }
  }
  return 0;
}
