#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') positive = 0;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
int N;
long long T[4][1005][1005];
inline long long Get(int t, int x, int y) {
  long long ans = 0;
  for (int i = min(x, N); i; i -= i & -i)
    for (int j = min(y, N); j; j -= j & -j) ans ^= T[t][i][j];
  return ans;
}
inline void Set(int t, int x, int y, long long v) {
  if (!x || !y) return;
  for (int i = x; i <= N; i += i & -i)
    for (int j = y; j <= N; j += j & -j) T[t][i][j] ^= v;
}
inline long long query(int x, int y) { return Get(x % 2 * 2 + y % 2, x, y); }
inline void modify(int x, int y, long long v) {
  if (x > N || y > N) return;
  int t = x % 2 * 2 + y % 2;
  Set(t, x, y, v);
}
int main() {
  N = read();
  int M = read();
  while (M--) {
    int ch = read(), x0 = read(), y0 = read(), x1 = read(), y1 = read();
    long long v;
    if (ch == 1)
      printf("%I64d\n", query(x1, y1) ^ query(x0 - 1, y1) ^ query(x1, y0 - 1) ^
                            query(x0 - 1, y0 - 1));
    else
      scanf("%I64d", &v), modify(x1 + 1, y1 + 1, v), modify(x0, y1 + 1, v),
          modify(x1 + 1, y0, v), modify(x0, y0, v);
  }
  return 0;
}
