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 100000+100
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 struct seg{int l,r;ll num[4],tag;}t[4*maxn];
61 int n,m;ll ans[4];
62 void build(int k,int l,int r)
63 {
64 t[k].l=l;t[k].r=r;t[k].tag=0;
65 if(l==r)return;
66 int mid=(l+r)>>1;
67 build(k<<1,l,mid);build(k<<1|1,mid+1,r);
68 }
69 inline void update(int k,ll z)
70 {
71 ll l=t[k].l,r=t[k].r;
72 t[k].tag+=z;
73 t[k].num[1]+=z*(r-l+1);
74 t[k].num[2]+=z*(r+l)*(r-l+1)/2;
75 t[k].num[3]+=z*(r*(r+1)*(2*r+1)-(l-1)*l*(2*l-1))/6;
76 }
77 inline void pushdown(int k)
78 {
79 if(!t[k].tag)return;
80 update(k<<1,t[k].tag);
81 update(k<<1|1,t[k].tag);
82 t[k].tag=0;
83 }
84 inline void pushup(int k)
85 {
86 for1(i,3)t[k].num[i]=t[k<<1].num[i]+t[k<<1|1].num[i];
87 }
88 void change(int k,int x,int y,ll z)
89 {
90 int l=t[k].l,r=t[k].r,mid=(l+r)>>1;
91 if(l==x&&r==y){update(k,z);return;}
92 pushdown(k);
93 if(y<=mid)change(k<<1,x,y,z);
94 else if(x>mid)change(k<<1|1,x,y,z);
95 else change(k<<1,x,mid,z),change(k<<1|1,mid+1,y,z);
96 pushup(k);
97 }
98 void query(int k,int x,int y,int z)
99 {
100 int l=t[k].l,r=t[k].r,mid=(l+r)>>1;
101 if(l==x&&r==y){ans[z]+=t[k].num[z];return;}
102 pushdown(k);
103 if(y<=mid)query(k<<1,x,y,z);
104 else if(x>mid)query(k<<1|1,x,y,z);
105 else query(k<<1,x,mid,z),query(k<<1|1,mid+1,y,z);
106 }
107 inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
108
109 int main()
110
111 {
112
113 freopen("input.txt","r",stdin);
114
115 freopen("output.txt","w",stdout);
116
117 n=read()-1;m=read();
118 build(1,1,n);
119 char ch[2];
120 while(m--)
121 {
122 scanf("%s",ch);
123 if(ch[0]==‘C‘)
124 {
125 int x=read(),y=read()-1;ll z=read();
126 change(1,x,y,z);
127 }
128 else
129 {
130 int xx=read(),yy=read()-1;ll x=xx,y=yy;
131 ll sum=(y-x+1)*(y-x+2)/2;
132 for1(i,3)ans[i]=0,query(1,xx,yy,i);
133 ans[0]=(y-x-x*y+1)*ans[1]+(y+x)*ans[2]-ans[3];
134 ll tmp=gcd(ans[0],sum);
135 printf("%lld/%lld\n",ans[0]/tmp,sum/tmp);
136 }
137 }
138
139 return 0;
140
141 }