#include <bits/stdc++.h>
using namespace std;
int id[2][2];
int n, m;
long long Bit[4][1010][1010];
inline void add(int T, int x, int y, long long v) {
  for (int i = x; i <= n; i += ((i) & (-i)))
    for (int j = y; j <= n; j += ((j) & (-j))) Bit[T][i][j] ^= v;
}
inline long long get_sum(int T, int x, int y) {
  long long s = 0;
  for (int i = x; i; i -= ((i) & (-i)))
    for (int j = y; j; j -= ((j) & (-j))) s ^= Bit[T][i][j];
  return s;
}
inline long long query(int x1, int y1, int x2, int y2) {
  long long s = get_sum(id[x2 & 1][y2 & 1], x2, y2);
  s ^= get_sum(id[x1 - 1 & 1][y1 - 1 & 1], x1 - 1, y1 - 1);
  s ^= get_sum(id[x1 - 1 & 1][y2 & 1], x1 - 1, y2);
  s ^= get_sum(id[x2 & 1][y1 - 1 & 1], x2, y1 - 1);
  return s;
}
inline void solve_1() {
  int x1, y1, x2, y2;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  printf("%I64d\n", query(x1, y1, x2, y2));
}
inline void solve_2() {
  int x1, y1, x2, y2;
  long long v;
  scanf("%d%d%d%d%lld", &x1, &y1, &x2, &y2, &v);
  add(id[x1 & 1][y1 & 1], x1, y1, v);
  add(id[x1 & 1][y2 + 1 & 1], x1, y2 + 1, v);
  add(id[x2 + 1 & 1][y1 & 1], x2 + 1, y1, v);
  add(id[x2 + 1 & 1][y2 + 1 & 1], x2 + 1, y2 + 1, v);
}
int main() {
  cin >> n >> m;
  id[0][0] = 0;
  id[0][1] = 1;
  id[1][0] = 2;
  id[1][1] = 3;
  for (int i = 1; i <= m; ++i) {
    int opt;
    scanf("%d", &opt);
    switch (opt) {
      case 1:
        solve_1();
        break;
      case 2:
        solve_2();
        break;
    }
  }
  return 0;
}
