#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=1e6+7;
ll seg[N*4],lazy[N*4],on[N*4],cnt[N*4];
ll state[N],point[N],nw[N];
void build(ll n,ll b,ll e){
if(b==e){
if(nw[b]==1) on[n]=1;
return;
}
ll mid=(b+e)/2;
build(2*n,b,mid);
build(2*n+1,mid+1,e);
on[n]=on[2*n]+on[2*n+1];
}
void update(ll n,ll b,ll e,ll l,ll r){
if(cnt[n]%2) on[n]=e-b+1-on[n];
if(b!=e) {
cnt[2*n]+=cnt[n];
cnt[2*n+1]+=cnt[n];
}
cnt[n]=0;
if(e<l || b>r) return;
if(b>=l && e<=r){
cnt[n]++;
if(b!=e){cnt[2*n]++;cnt[2*n+1]++;}
if(cnt[n]%2) on[n]=e-b+1-on[n];
cnt[n]=0;
return ;
}
ll mid=(b+e)/2;
update(2*n,b,mid,l,r);
update(2*n+1,mid+1,e,l,r);
on[n]=on[2*n]+on[2*n+1];
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n,m;cin>>n>>m;
ll ans=0;
ll neg[n+1]={0},id=1;
for(ll i=1;i<=n;i++){
cin>>state[i]>>point[i];
ans+=point[i];
if (state[i]!=-1){
nw[id]=state[i];
id++;
}
neg[i]=neg[i-1]+(state[i]==-1);
}
n=id-1;
build(1,1,n);
for(ll i=0;i<m;i++){
char ch;
cin>>ch;
if(ch=='C'){
ll val;cin>>val;
ans+=on[1]*val;
}
else{
ll l,r;cin>>l>>r;
l++;r++;
l-=neg[l-1];r-=neg[r];
if(l>r) continue;
update(1,1,n,l,r);
}
}
cout<<ans<<"\n";
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBsbCBsb25nIGxvbmcKCmNvbnN0IGxsIE49MWU2Kzc7CmxsIHNlZ1tOKjRdLGxhenlbTio0XSxvbltOKjRdLGNudFtOKjRdOwpsbCBzdGF0ZVtOXSxwb2ludFtOXSxud1tOXTsKCnZvaWQgYnVpbGQobGwgbixsbCBiLGxsIGUpewogICAgaWYoYj09ZSl7CiAgICAgICAgaWYobndbYl09PTEpIG9uW25dPTE7CiAgICAgICAgcmV0dXJuOwogICAgfQogICAgbGwgbWlkPShiK2UpLzI7CiAgICBidWlsZCgyKm4sYixtaWQpOwogICAgYnVpbGQoMipuKzEsbWlkKzEsZSk7CiAgICBvbltuXT1vblsyKm5dK29uWzIqbisxXTsKfQp2b2lkIHVwZGF0ZShsbCBuLGxsIGIsbGwgZSxsbCBsLGxsIHIpeyAgICAKICAgCWlmKGNudFtuXSUyKSBvbltuXT1lLWIrMS1vbltuXTsKCWlmKGIhPWUpIHsKCQljbnRbMipuXSs9Y250W25dOwoJCWNudFsyKm4rMV0rPWNudFtuXTsKCX0KCWNudFtuXT0wOwogICAgaWYoZTxsIHx8IGI+cikgcmV0dXJuOwogICAgaWYoYj49bCAmJiBlPD1yKXsKICAgIAljbnRbbl0rKzsKICAgIAlpZihiIT1lKXtjbnRbMipuXSsrO2NudFsyKm4rMV0rKzt9CiAgICAgICAgaWYoY250W25dJTIpIG9uW25dPWUtYisxLW9uW25dOwogICAgICAgIGNudFtuXT0wOwogICAgICAgIHJldHVybiA7ICAgICAgICAgICAgICAgIAkgICAgICAgCiAgICB9CiAgICBsbCBtaWQ9KGIrZSkvMjsKICAgIHVwZGF0ZSgyKm4sYixtaWQsbCxyKTsKICAgIHVwZGF0ZSgyKm4rMSxtaWQrMSxlLGwscik7CiAgICBvbltuXT1vblsyKm5dK29uWzIqbisxXTsKfQoKaW50IG1haW4oKXsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7CiAgICBjaW4udGllKDApOwogICAgbGwgbixtO2Npbj4+bj4+bTsKICAgIGxsIGFucz0wOwogICAgbGwgbmVnW24rMV09ezB9LGlkPTE7CiAgICBmb3IobGwgaT0xO2k8PW47aSsrKXsKICAgICAgICBjaW4+PnN0YXRlW2ldPj5wb2ludFtpXTsKICAgICAgICBhbnMrPXBvaW50W2ldOwogICAgICAgIGlmIChzdGF0ZVtpXSE9LTEpewogICAgICAgIAlud1tpZF09c3RhdGVbaV07CiAgICAgICAgCWlkKys7CiAgICAJfQogICAgCW5lZ1tpXT1uZWdbaS0xXSsoc3RhdGVbaV09PS0xKTsKICAgIH0KICAgIG49aWQtMTsKICAgIGJ1aWxkKDEsMSxuKTsgCiAgICBmb3IobGwgaT0wO2k8bTtpKyspewogICAgICAgIGNoYXIgY2g7CiAgICAgICAgY2luPj5jaDsKICAgICAgICBpZihjaD09J0MnKXsKICAgICAgICAgICAgbGwgdmFsO2Npbj4+dmFsOwogICAgICAgICAgICBhbnMrPW9uWzFdKnZhbDsKICAgICAgICB9CiAgICAgICAgZWxzZXsgCiAgICAgICAgICAgIGxsIGwscjtjaW4+Pmw+PnI7CiAgICAgICAgICAgIGwrKztyKys7CiAgICAgICAgICAgIGwtPW5lZ1tsLTFdO3ItPW5lZ1tyXTsKICAgICAgICAgICAgaWYobD5yKSBjb250aW51ZTsKICAgICAgICAgICAgdXBkYXRlKDEsMSxuLGwscik7CiAgICAgICAgfQogICAgfQogICAgY291dDw8YW5zPDwiXG4iOwp9