#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-6;
const int INF = 0x3fffffff;
const long long LINF = INF * 1ll * INF;
const double PI = acos(-1.0);
using namespace std;
long long a[4][1005][1005];
int n;
class BIT {
 public:
  int lowbit(int x) { return x & -x; }
  void add(int pos, int x, int y, long long v) {
    for (int i = x; i <= n; i += lowbit(i))
      for (int j = y; j <= n; j += lowbit(j)) a[pos][i][j] ^= v;
  }
  long long sum(int pos, int x, int y) {
    long long ans = 0;
    for (int i = x; i; i -= lowbit(i))
      for (int j = y; j; j -= lowbit(j)) ans ^= a[pos][i][j];
    return ans;
  }
} bit;
inline int getPos(int x, int y) { return x + 2 * y; }
long long solve(int x1, int y1) {
  return bit.sum(getPos(x1 % 2, y1 % 2), x1, y1);
}
void update(int x1, int y1, long long v) {
  bit.add(getPos(x1 % 2, y1 % 2), x1, y1, v);
}
int main(void) {
  int m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int t;
    cin >> t;
    if (t == 2) {
      long long x0, x1, y0, y1, v;
      cin >> x0 >> y0 >> x1 >> y1 >> v;
      update(x0, y0, v);
      update(x0, y1 + 1, v);
      update(x1 + 1, y0, v);
      update(x1 + 1, y1 + 1, v);
    } else {
      long long ans = 0;
      long long x0, x1, y0, y1;
      cin >> x0 >> y0 >> x1 >> y1;
      ans ^= solve(x1, y1);
      ans ^= solve(x0 - 1, y0 - 1);
      ans ^= solve(x1, y0 - 1);
      ans ^= solve(x0 - 1, y1);
      cout << ans << endl;
    }
  }
}
