#include<stdio.h>
#include<stdlib.h>
int scan
(){int ip
=getc(stdin
),ret
=0;for(;ip
<'0'||ip
>'9';ip
=getc(stdin
));for(;ip
>='0'&&ip
<='9';ip
=getc(stdin
))ret
=ret
*10+ip
-'0';return ret
;} 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+CmludCBzY2FuKCl7aW50IGlwPWdldGMoc3RkaW4pLHJldD0wO2Zvcig7aXA8JzAnfHxpcD4nOSc7aXA9Z2V0YyhzdGRpbikpO2Zvcig7aXA+PScwJyYmaXA8PSc5JztpcD1nZXRjKHN0ZGluKSlyZXQ9cmV0KjEwK2lwLScwJztyZXR1cm4gcmV0O30KaW50IG1haW4oKXsKaW50IG4gLHEscixzLHQ9MCx1PTA7CmNoYXIgY1sxMF07Cm49c2NhbigpOwpxPXNjYW4oKTsKaW50ICpjb2w9KGludCAqKWNhbGxvYyhuLHNpemVvZihpbnQpKTsKaW50ICpyb3c9KGludCAqKWNhbGxvYyhuLHNpemVvZihpbnQpKTsKd2hpbGUocS0tKXsKc2NhbmYoIiVzIixjKTsgICAgIC8qIFNPTUUgRVJST1IgSEVSRSAgIGFuZCBob3cgdG8gdXNlIGdldGNoYXJfdW5sb2NrZWQgZm9yIGNoYXIgaGVyZSovCnI9c2NhbigpOwpzPXNjYW4oKTsKaWYoY1swXT09J1InKXsKICAgIHJvd1tyLTFdKz1zOwogICAgaWYocm93W3ItMV0+dSkKICAgICAgICB1PXJvd1tyLTFdOwp9CmVsc2UgewogICAgY29sW3ItMV0rPXM7CiAgICBpZihjb2xbci0xXT50KQogICAgICAgIHQ9Y29sW3ItMV07Cn0KfQpwcmludGYoIiVkIix0K3UpOwpmcmVlKHJvdyk7IGZyZWUoY29sKTsKcmV0dXJuIDA7Cn0K