1 #include<cstdio>
2
3 #include<cstdlib>
4
5 #include<cmath>
6
7 #include<cstring>
8
9 #include<algorithm>
10
11 #include<iostream>
12
13 #include<vector>
14
15 #include<map>
16
17 #include<set>
18
19 #include<queue>
20
21 #include<string>
22
23 #define inf 1000000000
24
25 #define maxn 2050
26
27 #define maxm 500+100
28
29 #define eps 1e-10
30
31 #define ll long long
32
33 #define pa pair<int,int>
34
35 #define for0(i,n) for(int i=0;i<=(n);i++)
36
37 #define for1(i,n) for(int i=1;i<=(n);i++)
38
39 #define for2(i,x,y) for(int i=(x);i<=(y);i++)
40
41 #define for3(i,x,y) for(int i=(x);i>=(y);i--)
42
43 #define mod 1000000007
44
45 using namespace std;
46
47 inline int read()
48
49 {
50
51 int x=0,f=1;char ch=getchar();
52
53 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
54
55 while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();}
56
57 return x*f;
58
59 }
60 int n,m,s[4][maxn][maxn];
61 inline void add(int z,int x,int y,int t)
62 {
63 for(int i=x;i<=n;i+=i&(-i))
64 for(int j=y;j<=m;j+=j&(-j))
65 s[z][i][j]+=t;
66 }
67 inline int sum(int z,int x,int y)
68 {
69 int t=0;
70 for(int i=x;i;i-=i&(-i))
71 for(int j=y;j;j-=j&(-j))
72 t+=s[z][i][j];
73 return t;
74 }
75 inline int getsum(int x,int y)
76 {
77 return (x+1)*(y+1)*sum(0,x,y)-(y+1)*sum(1,x,y)-(x+1)*sum(2,x,y)+sum(3,x,y);
78 }
79
80 int main()
81
82 {
83
84 freopen("input.txt","r",stdin);
85
86 freopen("output.txt","w",stdout);
87
88 n=read();m=read();char ch[2];
89 while(scanf("%s",ch)!=EOF)
90 {
91 if(ch[0]==‘L‘)
92 {
93 int x1=read(),y1=read(),x2=read(),y2=read(),z=read();
94 add(0,x1,y1,z); add(0,x2+1,y2+1,z); add(0,x2+1,y1,-z); add(0,x1,y2+1,-z);
95 add(1,x1,y1,z*x1); add(1,x2+1,y2+1,z*(x2+1)); add(1,x2+1,y1,-z*(x2+1)); add(1,x1,y2+1,-z*x1);
96 add(2,x1,y1,z*y1); add(2,x2+1,y2+1,z*(y2+1)); add(2,x2+1,y1,-z*y1); add(2,x1,y2+1,-z*(y2+1));
97 add(3,x1,y1,z*x1*y1);add(3,x2+1,y2+1,z*(x2+1)*(y2+1));add(3,x2+1,y1,-z*(x2+1)*y1);add(3,x1,y2+1,-z*x1*(y2+1));
98 }
99 else
100 {
101 int x1=read(),y1=read(),x2=read(),y2=read();
102 printf("%d\n",getsum(x1-1,y1-1)+getsum(x2,y2)-getsum(x2,y1-1)-getsum(x1-1,y2));
103 }
104 }
105
106 return 0;
107
108 }