#include <bits/stdc++.h>
using namespace std;
long long BIT[4][1024][1024];
int parity(int x0, int y0) {
  int res = 0;
  if (x0 % 2) {
    res += 1;
  }
  if (y0 % 2) {
    res += 2;
  }
  return res;
}
void update(int x, int y, long long v, int f) {
  for (int i = x; i <= 1005; i += (i & -i)) {
    for (int j = y; j <= 1005; j += (j & -j)) {
      BIT[f][i][j] ^= v;
    }
  }
}
long long quary(int x, int y, int f) {
  long long sum = 0;
  for (int i = x; i > 0; i -= (i & -i)) {
    for (int j = y; j > 0; j -= (j & -j)) {
      sum ^= BIT[f][i][j];
    }
  }
  return sum;
}
int main() {
  memset(BIT, 0, sizeof(BIT));
  int n, m;
  scanf("%d %d", &n, &m);
  while (m--) {
    int x, y, xx, yy, o;
    long long v;
    scanf("%d %d %d %d %d", &o, &x, &y, &xx, &yy);
    if (o == 1) {
      long long ans = 0;
      ans = quary(xx, yy, parity(xx, yy));
      ans ^= quary(x - 1, y - 1, parity(x - 1, y - 1));
      ans ^= quary(xx, y - 1, parity(xx, y - 1));
      ans ^= quary(x - 1, yy, parity(x - 1, yy));
      cout << ans << endl;
    } else {
      long long val;
      cin >> val;
      update(x, y, val, parity(x, y));
      update(x, yy + 1, val, parity(x, yy + 1));
      update(xx + 1, y, val, parity(xx + 1, y));
      update(xx + 1, yy + 1, val, parity(xx + 1, yy + 1));
    }
  }
}
