#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
int dblcmp(double d) {
  if (fabs(d) < eps) return 0;
  return d > eps ? 1 : -1;
}
long long ar[5][2111][2111];
int n, m;
inline void add(int x, int y, long long z) {
  if (!x || !y) return;
  if (x % 2 == 1 && y % 2 == 1) {
    for (int i = x; i <= n; i += i & (-i)) {
      for (int j = y; j <= m; j += j & (-j)) {
        ar[0][i][j] ^= z;
      }
    }
  }
  if (x % 2 == 1) {
    for (int i = x; i <= n; i += i & (-i)) {
      for (int j = y; j <= m; j += j & (-j)) {
        ar[1][i][j] ^= z;
      }
    }
  }
  if (y % 2 == 1) {
    for (int i = x; i <= n; i += i & (-i)) {
      for (int j = y; j <= m; j += j & (-j)) {
        ar[2][i][j] ^= z;
      }
    }
  }
  for (int i = x; i <= n; i += i & (-i)) {
    for (int j = y; j <= m; j += j & (-j)) {
      ar[3][i][j] ^= z;
    }
  }
}
inline long long getsum(int p, int x, int y) {
  long long s = 0;
  for (int i = x; i; i -= i & (-i)) {
    for (int j = y; j; j -= j & (-j)) {
      s ^= ar[p][i][j];
    }
  }
  return s;
}
inline long long get(int p, int a, int b, int c, int d) {
  return getsum(p, c, d) ^ getsum(p, c, b - 1) ^ getsum(p, a - 1, d) ^
         getsum(p, a - 1, b - 1);
}
inline long long query(int x, int y) {
  long long s = 0;
  for (int i = x; i; i -= i & (-i)) {
    for (int j = y; j; j -= j & (-j)) {
      s ^= ar[0][i][j];
    }
  }
  if (y % 2 == 1) s ^= get(1, 1, y + 1, x, m);
  if (x % 2 == 1) s ^= get(2, x + 1, 1, n, y);
  if (x % 2 == 1 && y % 2 == 1) s ^= get(3, x + 1, y + 1, n, m);
  return s;
}
int main() {
  int i, j, k, q;
  scanf("%d%d", &n, &q);
  m = n;
  while (q--) {
    int o;
    scanf("%d", &o);
    if (o == 2) {
      int a, b, c, d;
      long long e;
      scanf("%d%d%d%d%I64d", &a, &b, &c, &d, &e);
      add(c, d, e);
      add(c, b - 1, e);
      add(a - 1, d, e);
      add(a - 1, b - 1, e);
    } else {
      int a, b, c, d;
      scanf("%d%d%d%d", &a, &b, &c, &d);
      printf("%I64d\n", query(c, d) ^ query(c, b - 1) ^ query(a - 1, d) ^
                            query(a - 1, b - 1));
    }
  }
  return 0;
}
