#include "testlib.h"
#include <iostream>
#include <vector>
#include <algorithm>

const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

bool isDigit(char c)
{
  return (c <= '9' && c >= '0');
}


int main(int argc, char* argv[])
{
	registerTestlibCmd(argc, argv);
	char c = ans.readChar();
	long long len = 0;
	bool checkingFailure = false;

	if (c == 'I')
	{
	  	std::string s = ouf.readToken();
	  	if (s == "Impossible")
	  		quit(_ok, "OK");
	  	else
	  	if (ouf.seekEoln())
	  	    quit(_pe, "Integer or \"Impossible\" expected");
	  	else
	  	{ 
	  	  	checkingFailure = true;
	  	  	for(int i = 0; i < (int)s.length(); i++){
	  	  	   if (!isDigit(s[i]))
	  	  	   {
	  	  	       quit(_pe, "Integer expected");
	  	  	   }
	  	  	   len = len * 10 + (int)(s[i] - '0');
	  	  	   if (len > 1000000)
	  	  	   {
	  	  	       quit(_pe, "Integer violates (1, 1000000) bounds");
	  	  	   }
	  	  	}
	  	  	  
	  	}
	}

	long long x = inf.readInt();
	long long y = inf.readInt();
//	std::cerr << x << " " << y << std::endl;

	int n = inf.readInt();
	inf.readEoln();

	int dir = 0;

	long long tx = 0;
	long long ty = 0;

//			std::cerr << tx << " " << ty << " " << dir << std::endl;
	if (!checkingFailure)
		len = ouf.readInt(1, 1000000);
	tx += len * dx[dir];
	ty += len * dy[dir];
//			std::cerr << tx << " " << ty << " " << dir << std::endl;

	for(int i = 0 ; i < n - 1 ; i ++)
	{
	  	char c = inf.readChar();
//	  	std::cerr << c << std::endl;
	  	if (c == 'R') dir++;
	  		else dir--;

	  	dir = (dir + 8) % 4;
	  	len = ouf.readInt(1, 1000000);
		tx += len * dx[dir];
		ty += len * dy[dir];
//			std::cerr << tx << " " << ty << " " << dir << std::endl;
	}
	
	if ((x != tx) || (y != ty))
	{
	  	quitf(_wa, "Final position is (%I64d, %I64d) instead of (%I64d, %I64d)", tx, ty, x, y);
	}
	if (checkingFailure)
	{
		quit(_fail, "Contestant found solution, while jury didn't");
	}
	quit(_ok, "OK");
}
