#include <iostream>
#include <string>

using namespace std;
struct P
{
	int x, y;
	int direction;		//0:North 1:East 2:South 3:West
};

void solve()
{
	int W, H;
	while(cin >> W >> H, W || H)
	{
		P p;
		p.x = 0;
		p.y = 0;
		p.direction = 0;
		string str;
		while(cin >> str)
		{
			if(str == "STOP")
			{
				cout << p.x + 1 << " " << p.y + 1 << endl;
				break;
			}
			else if(str == "FORWARD" || str == "BACKWARD")
			{
				int move;
				cin >> move;
				if(str == "FORWARD" && p.direction == 0 || str == "BACKWARD" && p.direction == 2)
				{
					p.y += move;
					if(p.y >= H)
					{
						p.y = H - 1;
					}
				}
				else if(str == "FORWARD" && p.direction == 2 || str == "BACKWARD" && p.direction == 0)
				{
					p.y-= move;
					if(p.y < 0)
					{
						p.y = 0;
					}
				}
				else if(str == "FORWARD" && p.direction == 1 || str == "BACKWARD" && p.direction == 3)
				{
					p.x += move;
					if(p.x >= W)
					{
						p.x = W - 1;
					}
				}
				else if(str == "FORWARD" && p.direction == 3 || str == "BACKWARD" && p.direction == 1)
				{
					p.x -= move;
					if(p.x < 0)
					{
						p.x = 0;
					}
				}	
			}
			else
			{
				if(str == "RIGHT")
				{
					p.direction = (p.direction + 1) % 4;		//cw
				}
				else if(str == "LEFT")
				{
					p.direction = (p.direction + 3) % 4;		//ccw
				}
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}