#include<stdio.h>
#include<string.h>




int main(void){
&#160; struct place{
&#160; &#160; char x,y,dir;
&#160; } now;
&#160; unsigned int m,n;
&#160; int k;
&#160; char input[32],command[16];




&#160; while(scanf("%u%u%*c",&m,&n) && m && n){
&#160; &#160; now=(struct place){1,1,0};
&#160; &#160;&#160;
&#160; &#160; while(scanf("%31[^\n]%*c",input) && strcmp(input,"STOP")){
&#160; &#160; &#160; if(!strcmp(input,"RIGHT")){
	now.dir+=1;
	now.dir%=4;
	continue;
&#160; &#160; &#160; }else if(!strcmp(input,"LEFT")){
	now.dir+=3;
	now.dir%=4;
	continue;
&#160; &#160; &#160; }
&#160; &#160; &#160; sscanf(input,"%15s%d",command,&k);
&#160; &#160; &#160; if(!strcmp(command,"BACKWARD")) k*=-1;
&#160; &#160; &#160; if(now.dir%2){
	k*=(now.dir==3)?-1:1;
	now.x+=k;
	if(now.x<1) now.x=1;
	else if(now.x>m) now.x=m;
&#160; &#160; &#160; }else{
	k*=(now.dir==2)?-1:1;
	now.y+=k;
	if(now.y<1) now.y=1;
	else if(now.y>n) now.y=n;
&#160; &#160; &#160; }
&#160; &#160; }
&#160; &#160; printf("%d %d\n",now.x,now.y);
&#160; }
&#160; return 0;
}