#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define lowbit(x) -x&x
typedef long long LL;
using namespace std;
const int N = 1024 * 4 + 10;
LL tr[N][N];
LL n, m;
void add(LL x, LL y, LL z)
{
for (LL i = x; i <= n; i += lowbit(i))
for (LL j = y; j <= m; j += lowbit(j))
tr[i][j] += z;
}
LL sum(LL x, LL y)
{
LL res = 0;
for (LL i = x; i; i -= lowbit(i))
for (LL j = y; j; j -= lowbit(j))
res += tr[i][j];
return res;
}
LL sum2(LL x1, LL y1, LL x2, LL y2)
{
return sum(x2, y2) - sum(x2, y1 - 1) - sum(x1 - 1, y2) + sum(x1 - 1, y1 - 1);
}
int main()
{
cin >> n >> m;
LL op;
LL x1, y1, x2, y2, z;
while (scanf("%lld", &op) != EOF){
if (op == 1){
scanf("%lld%lld%lld", &x1, &y1, &z);
add(x1, y1, z);
}else{
scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
printf("%lld\n", sum2(x1, y1, x2, y2));
}
}
return 0;
}
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define lowbit(x) -x&x
typedef long long LL;
using namespace std;
const int N = 1024 * 4 + 10;
LL tr[N][N];
LL n, m;
void add(LL x, LL y, LL z)
{
for (LL i = x; i <= n; i += lowbit(i))
for (LL j = y; j <= m; j += lowbit(j))
tr[i][j] += z;
}
LL sum(LL x, LL y)
{
LL res = 0;
for (LL i = x; i; i -= lowbit(i))
for (LL j = y; j; j -= lowbit(j))
res += tr[i][j];
return res;
}
LL sum2(LL x1, LL y1, LL x2, LL y2)
{
return sum(x2, y2) - sum(x2, y1 - 1) - sum(x1 - 1, y2) + sum(x1 - 1, y1 - 1);
}
int main()
{
cin >> n >> m;
LL op;
LL x1, y1, x2, y2, z;
while (scanf("%lld", &op) != EOF){
if (op == 1){
scanf("%lld%lld%lld%lld%lld", &x1, &y1, &x2, &y2, &z);
add(x1, y1, z), add(x2 + 1, y1, -z), add(x1, y2 + 1, -z), add(x2 + 1, y2 + 1, z);
}else{
scanf("%lld%lld", &x1, &y1);
printf("%lld\n", sum(x1, y1));
}
}
return 0;
}
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define lowbit(x) -x&x
typedef long long LL;
using namespace std;
const int N = 1024 * 4 + 10;
LL tr1[N][N], tr2[N][N], tr3[N][N], tr4[N][N];
LL n, m;
void add(LL x, LL y, LL z)
{
for (LL i = x; i <= n; i += lowbit(i))
for (LL j = y; j <= m; j += lowbit(j)){
tr1[i][j] += z;
tr2[i][j] += z * x;
tr3[i][j] += z * y;
tr4[i][j] += z * x * y;
}
}
LL sum(LL x, LL y)
{
LL res = 0;
for (LL i = x; i; i -= lowbit(i))
for (LL j = y; j; j -= lowbit(j))
res += tr1[i][j] * (x + 1) * (y + 1) - tr2[i][j] * (y + 1) - tr3[i][j] * (x + 1) + tr4[i][j];
return res;
}
LL sum2(LL x1, LL y1, LL x2, LL y2)
{
return sum(x2, y2) - sum(x2, y1 - 1) - sum(x1 - 1, y2) + sum(x1 - 1, y1 - 1);
}
int main()
{
cin >> n >> m;
LL op;
LL x1, y1, x2, y2, z;
while (scanf("%lld", &op) != EOF){
if (op == 1){
scanf("%lld%lld%lld%lld%lld", &x1, &y1, &x2, &y2, &z);
add(x1, y1, z), add(x2 + 1, y1, -z), add(x1, y2 + 1, -z), add(x2 + 1, y2 + 1, z);
}else{
scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
printf("%lld\n", sum2(x1, y1, x2, y2));
}
}
return 0;
}