#include <bits/stdc++.h>
using namespace std;
int dp1[1010][1010], dp2[1010][1010], dp3[1010][1010], dp4[1010][1010], war;
void add1(int xx, int yy) {
  for (int x = xx; x; x -= (x & -x))
    for (int y = yy; y; y -= (y & -y)) dp1[x][y] ^= war;
}
void add2(int xx, int yy) {
  for (int x = xx; x; x -= (x & -x))
    for (int y = yy; y < 1010; y += (y & -y)) dp2[x][y] ^= war;
}
void add3(int xx, int yy) {
  for (int x = xx; x < 1010; x += (x & -x))
    for (int y = yy; y; y -= (y & -y)) dp3[x][y] ^= war;
}
void add4(int xx, int yy) {
  for (int x = xx; x < 1010; x += (x & -x))
    for (int y = yy; y < 1010; y += (y & -y)) dp4[x][y] ^= war;
}
int sum1(int xx, int yy) {
  int wyn = 0;
  for (int x = xx; x < 1010; x += (x & -x))
    for (int y = yy; y < 1010; y += (y & -y)) wyn ^= dp1[x][y];
  return wyn;
}
int sum2(int xx, int yy) {
  int wyn = 0;
  for (int x = xx; x < 1010; x += (x & -x))
    for (int y = yy; y; y -= (y & -y)) wyn ^= dp2[x][y];
  return wyn;
}
int sum3(int xx, int yy) {
  int wyn = 0;
  for (int x = xx; x; x -= (x & -x))
    for (int y = yy; y < 1010; y += (y & -y)) wyn ^= dp3[x][y];
  return wyn;
}
int sum4(int xx, int yy) {
  int wyn = 0;
  for (int x = xx; x; x -= (x & -x))
    for (int y = yy; y; y -= (y & -y)) wyn ^= dp4[x][y];
  return wyn;
}
void addd(int x, int y) {
  add1(x, y);
  if (y & 1) add2(x, y);
  if (x & 1) add3(x, y);
  if (y & x & 1) add4(x, y);
}
int summ(int x, int y) {
  int wyn = 0;
  if (x & y & 1) wyn ^= sum1(x + 1, y + 1);
  if (x & 1) wyn ^= sum2(x + 1, y);
  if (y & 1) wyn ^= sum3(x, y + 1);
  wyn ^= sum4(x, y);
  return wyn;
}
void add(int x1, int y1, int x2, int y2) {
  addd(x2, y2);
  addd(x2, y1);
  addd(x1, y2);
  addd(x1, y1);
}
int sum(int x1, int y1, int x2, int y2) {
  return summ(x2, y2) ^ summ(x1, y2) ^ summ(x2, y1) ^ summ(x1, y1);
}
int q;
int main() {
  scanf("%*d%d", &q);
  while (q--) {
    int z, a, b, c, d;
    scanf("%d%d%d%d%d", &z, &a, &b, &c, &d);
    if (z == 1)
      printf("%d\n", sum(a, b, c + 1, d + 1));
    else {
      scanf("%I64d", &war);
      add(a, b, c + 1, d + 1);
    }
  }
}
