#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>

char arr[16][12];
char c1, c2;
bool used[16][8];
const int w = 8, h = 16;

using namespace std;

int dfs(int x, int y)
{
	if (used[y][x]) return 0;
	used[y][x] = true;
	if (arr[y][x] == '*')
		return 1;
	int cur = 1;
	if (x + 1 < w && (arr[y][x] == arr[y][x+1] || arr[y][x+1] == '*'))
		cur += dfs(x+1, y);
	if (x - 1 >= 0 && (arr[y][x] == arr[y][x-1] || arr[y][x-1] == '*'))
		cur += dfs(x-1, y);
	if (y + 1 < h  && (arr[y][x] == arr[y+1][x]  || arr[y+1][x] == '*'))
		cur += dfs(x, y+1);
	if (y - 1 >= 0 && (arr[y][x] == arr[y-1][x]  || arr[y-1][x] == '*'))
		cur += dfs(x, y-1);
	return cur;
}

pair<int, int> f(int left, int rotate)
{
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			used[i][j] = false;


	int x1 = left;
	int x2 = left;
	if (rotate == 0 || rotate == 2) ++x2;
	if (rotate == 2) swap(x1, x2);
	int y1;
	int y2;
	if (rotate == 1)
	{
		for (y2 = 0; y2 < h && arr[y2][x2] == '.'; ++y2);
		--y2;
		if (y2 == -1) return make_pair(-1, -1);
		arr[y2][x2] = c2;

		for (y1 = 0; y1 < h && arr[y1][x1] == '.'; ++y1);
		--y1;
		if (y1 == -1) return make_pair(-1, -1);
		arr[y1][x1] = c1;




	}
	else
	{
		for (y1 = 0; y1 < h && arr[y1][x1] == '.'; ++y1);
		--y1;
		if (y1 == -1) return make_pair(-1, -1);
		arr[y1][x1] = c1;


		for (y2 = 0; y2 < h && arr[y2][x2] == '.'; ++y2);
		--y2;
		if (y2 == -1) return make_pair(-1, -1);
		arr[y2][x2] = c2;

	}
	int c1 = dfs(x1, y1);
	int c2 = dfs(x2, y2);
	arr[y1][x1] = arr[y2][x2] = '.';
	return make_pair(c1, c2);
}

int main()
{
	//freopen("input.txt", "r", stdin);

	long long z1, z2;
	int st;


	for(int i = 0 ; ; ++i)
	{
		char str[100];
		scanf("%s",str);
		if(!strcmp(str,"Quit"))
		  break;
		if(!strcmp(str,"Start")) {
			scanf("%d", &st);
			printf("MISiS\n");
			z1 = st;
			fflush(stdout);
		}
		else if(!strcmp(str,"Move")) {
			for(int j = 0; j < h; j++)
				scanf("%s", &arr[j]);

			 
			z2 = (z1 * 17235617 + 4311271) % 87465851;
			c1 = '0' + (z1 % 5) + 1;
			c2 = '0' + (z2 % 5) + 1;
			z1 = (z2 * 17235617 + 4311271) % 87465851;

			pair<int, int> bestval = make_pair(-1, -1);
			int bestleft = -1, bestrotate = -1;
			for (int left = 0; left < w - 1; ++left) {
				for (int rotate = 0; rotate < 4; ++rotate) {
					pair<int, int> cur = f(left, rotate);
					if ((cur.first + cur.second > bestval.first + bestval.second) || (cur.first == bestval.first + bestval.second) || (cur.second > bestval.first + bestval.second))
					{
						bestleft = left;
						bestrotate = rotate;
						bestval = cur;
					}
				}
			}
					pair<int, int> cur = f(w-1, 1);
					if ((cur.first + cur.second > bestval.first + bestval.second) || (cur.first == bestval.first + bestval.second) || (cur.second > bestval.first + bestval.second))
					{
						bestleft = w-1;
						bestrotate = 1;
						bestval = cur;
					}
					
					cur = f(w-1, 3);
					if ((cur.first + cur.second > bestval.first + bestval.second) || (cur.first == bestval.first + bestval.second) || (cur.second > bestval.first + bestval.second))
					{
						bestleft = w-1;
						bestrotate = 3;
						bestval = cur;
					}



			for(int j = 0; j < h; j++)
				scanf("%*s");
			if (bestval.first + bestval.second <= 2)
			{
				int minj = -1;
				int bheight = -1;
				for (int j = 0; j < w; ++j) {
					int height = 0;
					while(arr[height][h] == '.')
						++height;
					if (height > bheight) {
						bheight = height;
						minj = j;
					}
				}
				printf("%d %d\n", minj, 1);
			}
			else
			printf("%d %d\n", bestleft, bestrotate);
			fflush(stdout);
		}
	}

	return 0;
}