#include <bits/stdc++.h>
using namespace std;
const int block_size = 320;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 7;
const long double eps = 1e-9;
const double PI = atan(1) * 4;
template <typename T>
inline int sign(const T &a) {
  if (a < 0) return -1;
  if (a > 0) return 1;
  return 0;
}
template <typename T, typename S>
inline bool upmin(T &a, const S &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T, typename S>
inline bool upmax(T &a, const S &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline void in(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
long long twop(int x) { return 1LL << x; }
template <typename A, typename B>
inline void in(A &x, B &y) {
  in(x);
  in(y);
}
template <typename A, typename B, typename C>
inline void in(A &x, B &y, C &z) {
  in(x);
  in(y);
  in(z);
}
template <typename A, typename B, typename C, typename D>
inline void in(A &x, B &y, C &z, D &d) {
  in(x);
  in(y);
  in(z);
  in(d);
}
long long bit[4][1010][1010];
int n, m;
void update(const int x, const int y, long long v) {
  for (int i = x; i <= n; i += (i & (-i))) {
    for (int j = y; j <= n; j += (j & (-j))) {
      bit[(x % 2) * 2 + y % 2][i][j] ^= v;
    }
  }
}
long long query(const int x, const int y) {
  long long ans = 0;
  for (int i = x; i; i -= (i & (-i))) {
    for (int j = y; j; j -= (j & (-j))) {
      ans ^= bit[(x % 2) * 2 + y % 2][i][j];
    }
  }
  return ans;
}
long long opt[500][5];
int cnt = 0;
int main() {
  in(n, m);
  for (long long i = 0; i < m; i++) {
    int t;
    in(t);
    int x1, y1, x2, y2;
    in(x1, y1, x2, y2);
    if (t == 1) {
      printf("%lld\n", query(x1 - 1, y1 - 1) ^ query(x1 - 1, y2) ^
                           query(x2, y1 - 1) ^ query(x2, y2));
    } else {
      long long v;
      in(v);
      update(x1, y1, v);
      update(x1, y2 + 1, v);
      update(x2 + 1, y1, v);
      update(x2 + 1, y2 + 1, v);
    }
  }
  return 0;
}
