#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_CONST

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <random>

using namespace std;

#pragma comment(linker, "/STACK:16777216")

typedef vector<int>::iterator vecit;
typedef set<int>::iterator setit;

enum
{
	pleft = 2,
	pright = 0,
	pup = 3,
	pdown = 1
};


char str[100];

char mymap[16][9];
char opmap[16][9];

long long x0;

void getnext(int & x1, int & x2)
{
	x1 = x0 % 5;
	long long xx = (int)((x0 * 17235617 + 4311271) % 87465851);
	x2 = xx % 5;
	x0 = (int)((xx * 17235617 + 4311271) % 87465851);
}

int change(int c)
{
	if (c%2) return c-1;
	return c+1;
}

queue<pair<int, int>> que;

int lcolors[] = {0,3,4,7,-1};
int unlike = 4;
//int lcolors[] = {0,3,4,7,-1};
//FILE * f;
int counts[8];
int getindex(int ind)
{
	for (int i = 0; i < 5; ++i)
	{
		if (lcolors[i] == ind) return i;
	}
	return  -1;
}

void  strat1()
{
	pair<int, int> p = que.front();
	que.pop();
	int b1,b2;
	int colnum;
	bool b = true;
	for (int j = 0; j < 8; ++j)
	{
		for (int i = 0; i < 16; ++i)
		{
			if (mymap[i][j] == '*')
			{
				counts[j] = 0;
				int ind = getindex(j);
				if (ind != -1)
				{
					lcolors[ind] = change(lcolors[ind]);
				}
				break;
			}
		}
	}
	if (p.first == p.second)
	{
		b1 = lcolors[p.first];
		if (b1 != -1)
		{
			colnum = lcolors[p.first];
			printf("%d %d\n", colnum, 3);
			counts[colnum] += 2;

			if (counts[colnum] >= 4)
			{
				counts[colnum] = 0;
				lcolors[p.first] = change(lcolors[p.first]);
				swap(lcolors[p.first], lcolors[unlike]);
				unlike = p.first;
			}
			/*if (p.first == 3)
			{
			fprintf(f,"q: %d %d\n", colnum, 3);
			fclose(f);
			}*/
		}
		else
		{
			colnum = abs(rand()%4);
			printf("%d %d\n", 5, 0);
		}
	}
	else if (lcolors[p.first] != -1)
	{
		colnum = lcolors[p.first];
		int qwer = (colnum % 2) ? -1 : 0;
		printf("%d %d\n", colnum + qwer, (colnum % 2) * 2);
		counts[lcolors[p.first]]++;


		if (counts[colnum] >= 4)
		{
			counts[colnum] = 0;
			lcolors[p.first] = change(lcolors[p.first]);
			swap(lcolors[p.first], lcolors[unlike]);
			unlike = p.first;
		}
		//fprintf(f,"q: %d %d\n", colnum , (colnum % 2) * 2);

	}
	else if (lcolors[p.second] != -1)
	{
		colnum = lcolors[p.second];
		int qwer = ((colnum +1)% 2) ? 0 : -1;
		printf("%d %d\n", colnum + qwer, ((colnum +1)% 2) * 2);
		counts[lcolors[p.second]]++;


		if (counts[colnum] >= 4)
		{
			counts[colnum] = 0;
			lcolors[p.second] = change(lcolors[p.second]);
			swap(lcolors[p.second], lcolors[unlike]);
			unlike = p.second;
		}
	}
	else
	{
		//b = false;
		colnum = abs(rand()%4);
		printf("%d %d\n", 1,1);
		//printf("%d %d\n", colnum * 2, 3);
		//colnum = abs(rand()%4);
		//printf("%d %d\n", colnum * 2, pup);
	}


	//colnum = lcolors[b1];
	//printf("%d %d\n", colnum, pright);

	//printf("%d %d\n", 1, 1);
	/*if (b)
	{
	}
	else
	{
	}*/

}


int main()
{
	//f = fopen("000.txt", "w");
	int maxs = 10;
	int w = 8, h = 16;
	int x1,x2;
	for(int step = 0 ; ; ++step)
	{
		scanf("%s",str);
		if(!strcmp(str,"Quit"))
			break;
		if(!strcmp(str,"Start")) 
		{
			scanf("%lld", &x0);

			printf("AbudiAbudai\n");

			//fprintf(f, "%d\n", x0);
			for (int i = 0; i < maxs; ++i)
			{
				getnext(x1, x2);
				que.push(make_pair(x1, x2));
				//fprintf(f, "%d %d\n", x1, x2);
			}
			//fclose(f);
			/*for (int i = 0; i < maxs; ++i)
			{
			*/
			fflush(stdout);
		}
		else if(!strcmp(str,"Move"))
		{
			getnext(x1, x2);
			que.push(make_pair(x1, x2));
			//printf("step %d\nmy:\n", step);

			for(int j = 0; j < h; j++)
			{
			scanf("%s", mymap[j]);
			//fprintf(f, "%s", mymap[j]);
			}

			//printf("op\n");
			for(int j = 0; j < h; j++)
			{
			scanf("%s", opmap[j]);
			//fprintf(f, "%s", opmap[j]);
			}

			strat1();
			//printf("%d %d\n", 1, 1);
			fflush(stdout);
		}
	}

	return 0;
}
