#include<iostream>#include<cstdio>usingnamespace std;#define ll long longconstint N =(1<<12)+5;int n, m;
ll c[N][N];intlowbit(int x){return x &(-x);}voidadd(int x,int y, ll t){for(int i = x; i <= n; i +=lowbit(i))for(int j = y; j <= m; j +=lowbit(j)){
c[i][j]+= t;}}
ll sum(int x,int y){
ll s =0;for(int i = x; i; i -=lowbit(i))for(int j = y; j; j -=lowbit(j))
s += c[i][j];return s;}intmain(){int op;scanf("%d%d",&n,&m);while(~scanf("%d",&op)){if(op ==1){int x, y;
ll k;scanf("%d%d%lld",&x,&y,&k);add(x, y, k);}else{int a, b, c, d;scanf("%d%d%d%d",&a,&b,&c,&d);printf("%lld\n",sum(c, d)-sum(c, b -1)-sum(a -1, d)+sum(a -1, b -1));}}return0;}
#include<iostream>#include<cstdio>usingnamespace std;#define ll long longconst ll N =(1<<11)+5;
ll n, m;
ll c[4][N][N];
ll lowbit(ll x){return x &(-x);}voidadd(ll x, ll y, ll d){for(ll i = x; i <= n; i +=lowbit(i))for(ll j = y; j <= m; j +=lowbit(j)){
c[0][i][j]+= d;
c[1][i][j]+= d * x;
c[2][i][j]+= d * y;
c[3][i][j]+= d * x * y;}}
ll sum(ll x, ll y){
ll s =0;for(ll i = x; i; i -=lowbit(i))for(ll j = y; j; j -=lowbit(j))
s +=(x +1)*(y +1)* c[0][i][j]-(y +1)* c[1][i][j]-(x +1)* c[2][i][j]+ c[3][i][j];return s;}intmain(){
ll op, x;scanf("%lld%lld",&n,&m);while(~scanf("%lld",&op)){
ll a, b, c, d;scanf("%lld%lld%lld%lld",&a,&b,&c,&d);if(op ==1){scanf("%lld",&x);add(a, b, x);add(a, d +1,-x);add(c +1, b,-x);add(c +1, d +1, x);}else{printf("%lld\n",sum(c, d)-sum(a -1, d)-sum(c, b -1)+sum(a -1, b -1));}}return0;}