#include <bits/stdc++.h>
using namespace std;
const int INFint = 2e9;
const long long INF = (long long)2e18;
const int MOD = 1e9 + 7;
struct fenwick_tree {
  vector<vector<long long> > t[4];
  int n, m;
  int get(int x, int y) {
    if (x % 2 == 0 && y % 2 == 0) return 0;
    if (x % 2 == 0 && y % 2 == 1) return 1;
    if (x % 2 == 1 && y % 2 == 0) return 2;
    return 3;
  }
  long long sum(int x, int y) {
    long long result = 0;
    int p = get(x, y);
    for (int i = x; i >= 0; i = (i & (i + 1)) - 1)
      for (int j = y; j >= 0; j = (j & (j + 1)) - 1) result ^= t[p][i][j];
    return result;
  }
  void inc(int x, int y, long long delta) {
    int p = get(x, y);
    for (int i = x; i < n; i = (i | (i + 1)))
      for (int j = y; j < m; j = (j | (j + 1))) t[p][i][j] ^= delta;
  }
  fenwick_tree(int x) {
    n = x;
    m = x;
    for (int it = 0; it < 4; it++) t[it].resize(n, vector<long long>(n));
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  fenwick_tree ft(n + 2);
  for (; m--;) {
    int t, x1, y1, x2, y2;
    cin >> t >> x1 >> y1 >> x2 >> y2;
    if (t == 2) {
      long long v;
      cin >> v;
      ft.inc(x1, y1, v);
      ft.inc(x2 + 1, y2 + 1, v);
      ft.inc(x1, y2 + 1, v);
      ft.inc(x2 + 1, y1, v);
      continue;
    }
    long long res = ft.sum(x2, y2);
    res ^= ft.sum(x1 - 1, y2);
    res ^= ft.sum(x2, y1 - 1);
    res ^= ft.sum(x1 - 1, y1 - 1);
    cout << res << endl;
  }
  fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock() / CLOCKS_PER_SEC);
  ;
  return 0;
}
