#include<stdio.h>
#include<stdlib.h>
int scan()
{
int n=0;
int ch=getchar_unlocked();
while(ch<'0'||ch>'9')
ch=getchar_unlocked();
while(ch>='0'&&ch<='9')
n=(n<<3)+(n<<1)+ch-'0',ch=getchar_unlocked();
return n;
}
int main(){
int n ,q,r,s,t=0,u=0;
char c[10];
n=scan();
q=scan();
int *col
=(int *)calloc(n
,sizeof(int)); int *row
=(int *)calloc(n
,sizeof(int)); while(q--){
scanf("%s",c
); /* SOME ERROR HERE and how to use getchar_unlocked for char here*/ r=scan();
s=scan();
if(c[0]=='R'){
row[r-1]+=s;
if(row[r-1]>u)
u=row[r-1];
}
else {
col[r-1]+=s;
if(col[r-1]>t)
t=col[r-1];
}
}
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RkbGliLmg+CgppbnQgc2NhbigpIAp7CiAgICBpbnQgbj0wOwogICAgaW50IGNoPWdldGNoYXJfdW5sb2NrZWQoKTsKICAgIHdoaWxlKGNoPCcwJ3x8Y2g+JzknKQogICAgICAgIGNoPWdldGNoYXJfdW5sb2NrZWQoKTsKICAgIHdoaWxlKGNoPj0nMCcmJmNoPD0nOScpCiAgICAgICAgbj0objw8MykrKG48PDEpK2NoLScwJyxjaD1nZXRjaGFyX3VubG9ja2VkKCk7CiAgICByZXR1cm4gbjsKfQoKaW50IG1haW4oKXsKaW50IG4gLHEscixzLHQ9MCx1PTA7CmNoYXIgY1sxMF07Cm49c2NhbigpOwpxPXNjYW4oKTsKaW50ICpjb2w9KGludCAqKWNhbGxvYyhuLHNpemVvZihpbnQpKTsKaW50ICpyb3c9KGludCAqKWNhbGxvYyhuLHNpemVvZihpbnQpKTsKd2hpbGUocS0tKXsKc2NhbmYoIiVzIixjKTsgICAgIC8qIFNPTUUgRVJST1IgSEVSRSAgIGFuZCBob3cgdG8gdXNlIGdldGNoYXJfdW5sb2NrZWQgZm9yIGNoYXIgaGVyZSovCnI9c2NhbigpOwpzPXNjYW4oKTsKaWYoY1swXT09J1InKXsKICAgIHJvd1tyLTFdKz1zOwogICAgaWYocm93W3ItMV0+dSkKICAgICAgICB1PXJvd1tyLTFdOwp9CmVsc2UgewogICAgY29sW3ItMV0rPXM7CiAgICBpZihjb2xbci0xXT50KQogICAgICAgIHQ9Y29sW3ItMV07Cn0KfQpwcmludGYoIiVkIix0K3UpOwpmcmVlKHJvdyk7IGZyZWUoY29sKTsKcmV0dXJuIDA7Cn0K