var
a:array[0..128,0..128,0..128] of int64;
n,q,w,e,temp,x1,x2,y1,y2,z1,z2:longint;
function add(q,w,e,x:longint):longint;
var
z,c:longint;
begin
z:=w;
c:=e;
while q <= n do
begin
while z <= n do
begin
while c <= n do
begin
inc(a[q,z,c],x);
c:=c or (c + 1);
end;
c:=e;
z:=z or (z + 1);
end;
z:=w;
q:=q or (q + 1);
end;
end;
function sum(q,w,e:longint):int64;
var
t:int64;
begin
t := 0;
while q >= 0 do
begin
while w >= 0 do
begin
while e >= 0 do
begin
inc(t,a[q,w,e]);
e:=(e and (e + 1)) - 1;
end;
w:=(w and (w + 1)) - 1;
end;
q:=(q and (q + 1)) - 1;
end;
sum:=t;
end;
begin
{assign(input,'stars.in');
reset(input);
assign(output,'stars.out');
rewrite(output);}
read(n);
read(q);
while q<>3 do
begin
if q = 2 then
begin
temp:=0;
read(x1,y1,z1,x2,y2,z2);
inc(temp,+sum(x2 + 0,y2 + 0,z2 + 0));
inc(temp,-sum(x1 - 1,y2 + 0,z2 + 0));
inc(temp,-sum(x2 + 0,y1 - 1,z2 + 0));
inc(temp,-sum(x2 + 0,y2 + 0,z1 - 1));
inc(temp,+sum(x1 - 1,y1 - 1,z2 + 0));
inc(temp,+sum(x1 - 1,y2 + 0,z1 - 1));
inc(temp,+sum(x2 + 0,y1 - 1,z1 - 1));
inc(temp,-sum(x1 - 1,y1 - 1,z1 - 1));
writeln(temp);
end
else if q = 1 then
begin
read(x1,y1,z1,e);
add(x1,y1,z1,e);
end;
read(q);
end;
end.
dmFyCiAgYTphcnJheVswLi4xMjgsMC4uMTI4LDAuLjEyOF0gb2YgaW50NjQ7CiAgbixxLHcsZSx0ZW1wLHgxLHgyLHkxLHkyLHoxLHoyOmxvbmdpbnQ7CgpmdW5jdGlvbiBhZGQocSx3LGUseDpsb25naW50KTpsb25naW50Owp2YXIKICB6LGM6bG9uZ2ludDsKYmVnaW4KICB6Oj13OwogIGM6PWU7CiAgd2hpbGUgcSA8PSBuIGRvCiAgICBiZWdpbgogICAgICB3aGlsZSB6IDw9IG4gZG8KICAgICAgICBiZWdpbgogICAgICAgICAgd2hpbGUgYyA8PSBuIGRvCiAgICAgICAgICAgIGJlZ2luCiAgICAgICAgICAgICAgaW5jKGFbcSx6LGNdLHgpOwogICAgICAgICAgICAgIGM6PWMgb3IgKGMgKyAxKTsKICAgICAgICAgICAgZW5kOwogICAgICAgICAgYzo9ZTsKICAgICAgICAgIHo6PXogb3IgKHogKyAxKTsKICAgICAgICBlbmQ7CiAgICAgIHo6PXc7CiAgICAgIHE6PXEgb3IgKHEgKyAxKTsKICAgIGVuZDsKZW5kOwoKZnVuY3Rpb24gc3VtKHEsdyxlOmxvbmdpbnQpOmludDY0Owp2YXIKICB0OmludDY0OwpiZWdpbgogIHQgOj0gMDsKICB3aGlsZSBxID49IDAgZG8KICAgIGJlZ2luCiAgICAgIHdoaWxlIHcgPj0gMCBkbwogICAgICAgIGJlZ2luCiAgICAgICAgICB3aGlsZSBlID49IDAgZG8KICAgICAgICAgICAgYmVnaW4KICAgICAgICAgICAgICBpbmModCxhW3EsdyxlXSk7CiAgICAgICAgICAgICAgZTo9KGUgYW5kIChlICsgMSkpIC0gMTsKICAgICAgICAgICAgZW5kOwogICAgICAgICAgdzo9KHcgYW5kICh3ICsgMSkpIC0gMTsKICAgICAgICBlbmQ7CiAgICAgIHE6PShxIGFuZCAocSArIDEpKSAtIDE7CiAgICBlbmQ7CiAgc3VtOj10OwplbmQ7CgpiZWdpbgogIHthc3NpZ24oaW5wdXQsJ3N0YXJzLmluJyk7CiAgcmVzZXQoaW5wdXQpOwogIGFzc2lnbihvdXRwdXQsJ3N0YXJzLm91dCcpOwogIHJld3JpdGUob3V0cHV0KTt9CiAgcmVhZChuKTsKICByZWFkKHEpOwogIHdoaWxlIHE8PjMgZG8KICAgIGJlZ2luCiAgICAgIGlmIHEgPSAyIHRoZW4KICAgICAgICBiZWdpbgogICAgICAgICAgdGVtcDo9MDsKICAgICAgICAgIHJlYWQoeDEseTEsejEseDIseTIsejIpOwogICAgICAgICAgaW5jKHRlbXAsK3N1bSh4MiArIDAseTIgKyAwLHoyICsgMCkpOwogICAgICAgICAgaW5jKHRlbXAsLXN1bSh4MSAtIDEseTIgKyAwLHoyICsgMCkpOwogICAgICAgICAgaW5jKHRlbXAsLXN1bSh4MiArIDAseTEgLSAxLHoyICsgMCkpOwogICAgICAgICAgaW5jKHRlbXAsLXN1bSh4MiArIDAseTIgKyAwLHoxIC0gMSkpOwogICAgICAgICAgaW5jKHRlbXAsK3N1bSh4MSAtIDEseTEgLSAxLHoyICsgMCkpOwogICAgICAgICAgaW5jKHRlbXAsK3N1bSh4MSAtIDEseTIgKyAwLHoxIC0gMSkpOwogICAgICAgICAgaW5jKHRlbXAsK3N1bSh4MiArIDAseTEgLSAxLHoxIC0gMSkpOwogICAgICAgICAgaW5jKHRlbXAsLXN1bSh4MSAtIDEseTEgLSAxLHoxIC0gMSkpOwogICAgICAgICAgd3JpdGVsbih0ZW1wKTsKICAgICAgICBlbmQKICAgICAgZWxzZSBpZiBxID0gMSB0aGVuCiAgICAgICAgYmVnaW4KICAgICAgICAgIHJlYWQoeDEseTEsejEsZSk7CiAgICAgICAgICBhZGQoeDEseTEsejEsZSk7CiAgICAgICAgZW5kOwogICAgICByZWFkKHEpOwogICAgZW5kOwplbmQu