#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1010;
int N, M, Type, X1, Y1, X2, Y2;
long long Val, Aib[4][NMAX][NMAX];
int LSB(int X) { return (X & (X - 1)) ^ X; }
void Update(int X, int Y, long long Val) {
  int Index = (X % 2 ? 1 : 0) + (Y % 2 ? 2 : 0);
  for (int i = X; i <= N; i += LSB(i))
    for (int j = Y; j <= N; j += LSB(j)) Aib[Index][i][j] ^= Val;
}
long long Query(int X, int Y) {
  int Index = (X % 2 ? 1 : 0) + (Y % 2 ? 2 : 0);
  long long Ans = 0;
  for (int i = X; i; i -= LSB(i))
    for (int j = Y; j; j -= LSB(j)) Ans ^= Aib[Index][i][j];
  return Ans;
}
int main() {
  scanf("%i %i", &N, &M);
  for (; M; M--) {
    scanf("%i", &Type);
    if (Type == 1) {
      scanf("%i %i %i %i", &X1, &Y1, &X2, &Y2);
      long long Ans = Query(X2, Y2) ^ Query(X1 - 1, Y2) ^ Query(X2, Y1 - 1) ^
                      Query(X1 - 1, Y1 - 1);
      printf("%I64d\n", Ans);
    } else {
      scanf("%i %i %i %i %I64d", &X1, &Y1, &X2, &Y2, &Val);
      Update(X1, Y1, Val);
      Update(X2 + 1, Y1, Val);
      Update(X1, Y2 + 1, Val);
      Update(X2 + 1, Y2 + 1, Val);
    }
  }
}
