#include // c #include // io #include #include #include #include // container #include #include #include #include #include #include // other #include #include #include #include #include using namespace std; using ll =long long; #define ALL(c) (begin(c)),(end(c)) #define REP(i,n) FOR(i,0,n) #define REPr(i,n) FORr(i,0,n) #define FOR(i,l,r) for(int i=(int)(l);i<(int)(r);++i) #define FORr(i,l,r) for(int i=(int)(r)-1;i>=(int)(l);--i) #define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it) #define IN(l,v,r) ((l)<=(v) && (v)<(r)) #define UNIQUE(v) v.erase(unique(ALL(v)),v.end()) //debug #define DUMP(x) cerr << #x << " = " << (x) #define LINE() cerr<< " (L" << __LINE__ << ")" ll pmod(ll v,ll M){return (v%M+M)%M;} template class Fenwick{ public: int size;vector bit; Fenwick(int n):size(n){bit = vector(n+1);} T sum(int n){// [0,n) T s=0; while(n>0){ s+=bit[n]; n-=n&-n;//low } return s; } void add(int i,T x){//[0,...i...,n) i++; while(i<=size){ bit[i]+=x; i+=i & -i;//next } } T sum(int a,int b){// [a,b) return sum(b)-sum(a); } }; //O(Q * log(Q+N)) int main(){ cout <> N >> Q; Fenwick fenL(N+Q+1),fenR(N+Q+1); int wll=0,wlr=N-1,wrl=Q,wrr=Q + N-1; REP(t,Q){ char x;ll y,z;cin >> x >> y >> z; if(x=='L') fenL.add(t+y,z); if(x=='R') fenR.add(Q-t+y,z); if(x=='C'){ cout << fenL.sum(t + y,t + z) + fenR.sum(Q - t + y,Q-t + z)<