#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 + 10;
int n, m;
long long f[5][MAXN][MAXN];
int lowbit(int first) { return first & -first; }
void Add(long long f[][MAXN], int first, int second, long long v) {
  for (int i = first; i <= n; i += lowbit(i))
    for (int j = second; j <= n; j += lowbit(j)) f[i][j] ^= v;
}
long long Getsum(long long f[][MAXN], int first, int second) {
  long long Tohka = 0;
  for (int i = first; i; i -= lowbit(i))
    for (int j = second; j; j -= lowbit(j)) Tohka ^= f[i][j];
  return Tohka;
}
int Get(int first) { return (first - 1) / 2 + 1; }
long long Get(int first, int second) {
  if (first <= 0 || second <= 0) return 0;
  int s = (first & 1) * 2 + (second & 1);
  int nx = (first - 1) / 2 + 1, ny = (second - 1) / 2 + 1;
  return Getsum(f[s], nx, ny) ^ Getsum(f[4], first, second);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int ty, xl, xr, yl, yr;
    scanf("%d%d%d%d%d", &ty, &xl, &yl, &xr, &yr);
    if (ty == 1)
      cout << (Get(xr, yr) ^ Get(xr, yl - 1) ^ Get(xl - 1, yr) ^
               Get(xl - 1, yl - 1))
           << endl;
    else {
      long long v;
      cin >> v;
      int s = (xl & 1) * 2 + (yl & 1);
      int nxl = (xl - 1) / 2 + 1, nyl = (yl - 1) / 2 + 1,
          nxr = nxl + (xr - xl) / 2, nyr = nyl + (yr - yl) / 2;
      Add(f[s], nxl, nyl, v), Add(f[s], nxl, nyr + 1, v),
          Add(f[s], nxr + 1, nyl, v), Add(f[s], nxr + 1, nyr + 1, v);
      if ((xr - xl + 1) & 1)
        Add(f[s], nxr + 1, nyl, v), Add(f[s], nxr + 1, nyr + 1, v),
            Add(f[s ^ 2], Get(xr + 1), nyl, v),
            Add(f[s ^ 2], Get(xr + 1), nyr + 1, v);
      if ((yr - yl + 1) & 1)
        Add(f[s], nxl, nyr + 1, v), Add(f[s], nxr + 1, nyr + 1, v),
            Add(f[s ^ 1], nxl, Get(yr + 1), v),
            Add(f[s ^ 1], nxr + 1, Get(yr + 1), v);
      if (((xr - xl + 1) & 1) && ((yr - yl + 1) & 1))
        Add(f[4], xr + 1, yr + 1, v);
    }
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}
