#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int MAXN = 1e3 + 10;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double EPS = 1e-9;
inline int sgn(double a) {
  if (a < -EPS) return -1;
  return a > EPS;
}
inline int cmp(double a, double b) { return sgn(a - b); }
int n, m;
int lowbit(int x) { return x & -x; }
long long tree[2][2][MAXN][MAXN];
long long sum(int x, int y) {
  long long ret = 0;
  for (int xx = x; xx; xx -= lowbit(xx)) {
    for (int yy = y; yy; yy -= lowbit(yy)) {
      ret ^= tree[x & 1][y & 1][xx][yy];
    }
  }
  return ret;
}
void update(int x, int y, long long val) {
  for (int xx = x; xx <= n; xx += lowbit(xx)) {
    for (int yy = y; yy <= n; yy += lowbit(yy))
      tree[x & 1][y & 1][xx][yy] ^= val;
  }
}
void solve() {
  int ty, a, b, c, d;
  long long v;
  while (m--) {
    scanf("%d%d%d%d%d", &ty, &a, &b, &c, &d);
    if (ty == 2) {
      scanf("%lld", &v);
      update(c + 1, d + 1, v);
      update(a, d + 1, v);
      update(c + 1, b, v);
      update(a, b, v);
    } else {
      printf("%lld\n",
             sum(c, d) ^ sum(c, b - 1) ^ sum(a - 1, d) ^ sum(a - 1, b - 1));
    }
  }
}
void init() { scanf("%d%d", &n, &m); }
int main() {
  int T = 1;
  while (T--) {
    init();
    solve();
  }
  return 0;
}
