#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={0,1,0,-1};
const int dy[]={-1,0,1,0};
//int board[120][120];
int main(){
	int n,m;
	while(cin>>m>>n,n||m){
		int dir =0;
		int posx,posy;
		posx =posy=1;
		//memset(board, 0, sizeof(board));
		int nx,ny;
		nx=ny=1;
		while(true){
			//cout <<dir<<" "<<posx<<" "<<posy<<endl;
			string str;
			cin>>str;
			if(str=="FORWARD"){
				int d;
				cin>>d;
				if(dir==0){
					nx =posx;
					ny =min(posy+d,n); 
				}else if(dir==1){
					nx =min(posx+d,m);
					ny =posy;
				}else if(dir==2){
					nx =posx;
					ny =max(posy-d,1);
				}else if(dir==3){
					nx =max(posx-d,1);
					ny =posy;
				}
			}else if(str=="BACKWARD"){
				int d;
				cin>>d;
				if(dir==0){
					nx =posx;
					ny =max(posy-d,1); 
				}else if(dir==1){
					nx =max(posx-d,1);
					ny =posy;
				}else if(dir==2){
					nx =posx;
					ny =min(posy+d,n);
				}else if(dir==3){
					nx =min(posx+d,m);
					ny =posy;
				}
			}else if(str=="RIGHT"){
				dir =(dir+1)%4;
				nx =posx;
				ny =posy;
			}else if(str=="LEFT"){
				dir =(dir-1);
				if(dir<0){
					dir =3;
				}
				nx =posx;
				ny =posy;
			}else if(str=="STOP"){
				break;
			}
			posx =nx;
			posy =ny;
		}
		cout <<posx<<" "<<posy<<endl;
	}
	return 0;
}