#include <bits/stdc++.h>
using namespace std;
void Get(int &T) {
  char C;
  bool F = 0;
  for (; C = getchar(), C < '0' || C > '9';)
    if (C == '-') F = 1;
  for (T = C - '0'; C = getchar(), C >= '0' && C <= '9'; T = T * 10 + C - '0')
    ;
  F && (T = -T);
}
void Get(long long &T) {
  char C;
  bool F = 0;
  for (; C = getchar(), C < '0' || C > '9';)
    if (C == '-') F = 1;
  for (T = C - '0'; C = getchar(), C >= '0' && C <= '9'; T = T * 10 + C - '0')
    ;
  F && (T = -T);
}
int N, M;
void Init() {
  Get(N);
  Get(M);
}
long long F[1005][1005];
long long G1[1005][1005];
long long G2[1005][1005];
long long G3[1005][1005];
long long G4[1005][1005];
void Add(int X, int Y, long long Z) {
  for (int i = X; i <= N; i += i & -i)
    for (int j = Y; j <= N; j += j & -j) {
      F[i][j] ^= Z;
      if ((X & 1) == 0 && (Y & 1) == 0) G1[i][j] ^= Z;
      if ((X & 1) == 0 && (Y & 1) == 1) G2[i][j] ^= Z;
      if ((X & 1) == 1 && (Y & 1) == 0) G3[i][j] ^= Z;
      if ((X & 1) == 1 && (Y & 1) == 1) G4[i][j] ^= Z;
    }
}
long long Ask(long long F[][1005], int X, int Y) {
  long long Ans = 0;
  for (int i = X; i >= 1; i -= i & -i)
    for (int j = Y; j >= 1; j -= j & -j) Ans ^= F[i][j];
  return Ans;
}
void Work() {
  int Type;
  int X0;
  int X1;
  int Y0;
  int Y1;
  long long Z;
  for (int i = 1; i <= M; i++) {
    Get(Type);
    switch (Type) {
      case 2:
        Get(X0);
        Get(Y0);
        Get(X1);
        X1++;
        Get(Y1);
        Y1++;
        Get(Z);
        Add(X0, Y0, Z);
        Add(X1, Y0, Z);
        Add(X0, Y1, Z);
        Add(X1, Y1, Z);
        break;
      case 1:
        Get(X0);
        X0--;
        Get(Y0);
        Y0--;
        Get(X1);
        Get(Y1);
        long long Ans = 0;
        if ((X1 & 1) == 0 && (Y1 & 1) == 0)
          Ans ^= Ask(G1, X1, Y1) ^ Ask(G1, X1, Y0) ^ Ask(G1, X0, Y1) ^
                 Ask(G1, X0, Y0);
        if ((X1 & 1) == 0 && (Y1 & 1) == 1)
          Ans ^= Ask(G2, X1, Y1) ^ Ask(G2, X1, Y0) ^ Ask(G2, X0, Y1) ^
                 Ask(G2, X0, Y0);
        if ((X1 & 1) == 1 && (Y1 & 1) == 0)
          Ans ^= Ask(G3, X1, Y1) ^ Ask(G3, X1, Y0) ^ Ask(G3, X0, Y1) ^
                 Ask(G3, X0, Y0);
        if ((X1 & 1) == 1 && (Y1 & 1) == 1)
          Ans ^= Ask(G4, X1, Y1) ^ Ask(G4, X1, Y0) ^ Ask(G4, X0, Y1) ^
                 Ask(G4, X0, Y0);
        if (((X1 - X0) & 1)) {
          if ((Y1 & 1) == 1)
            Ans ^= Ask(G4, X0, Y1) ^ Ask(G4, X0, Y0) ^ Ask(G2, X0, Y1) ^
                   Ask(G2, X0, Y0);
          if ((Y1 & 1) == 0)
            Ans ^= Ask(G3, X0, Y1) ^ Ask(G3, X0, Y0) ^ Ask(G1, X0, Y1) ^
                   Ask(G1, X0, Y0);
        }
        if (((Y1 - Y0) & 1)) {
          if ((X1 & 1) == 1)
            Ans ^= Ask(G4, X1, Y0) ^ Ask(G4, X0, Y0) ^ Ask(G3, X1, Y0) ^
                   Ask(G3, X0, Y0);
          if ((X1 & 1) == 0)
            Ans ^= Ask(G2, X1, Y0) ^ Ask(G2, X0, Y0) ^ Ask(G1, X1, Y0) ^
                   Ask(G1, X0, Y0);
        }
        if (((X1 - X0) & 1) && ((Y1 - Y0) & 1)) {
          Ans ^= Ask(F, X0, Y0);
        }
        printf("%I64d\n", Ans);
    }
  }
}
int main() {
  Init();
  Work();
}
