#include using namespace std; #define NMAX 1000008 int main(){ int H,W; int N; char S[NMAX]; int K[NMAX]; int x=0,y=0; cin>>H>>W; cin>>N; for(int i=0;i>S[i]>>K[i]; } for(int i=N-1;i>=0;i--){ if(S[i]=='C'&&K[i]==y){ x--; if(x==-1) x=W-1; } else if(S[i]=='R'&&K[i]==x){ y--; if(y==-1) y=H-1; } } int a=0,b=0; for(int i=0;i