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

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

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