#include <cstdio>
#include <cstring>
#include <memory.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

const int W = 8;
const int H = 16;
const int MAGIC[] = {0,0,3,6,12,24,50,100,100,100,100,100,100,100,100,100,100,100
,100,100,100,100,100,100,100,100,100,100,100
,100,100,100,100,100,100,100,100,100,100,100
,100,100,100,100,100,100,100,100,100,100,100
};

int SECOND_LEVEL = 2;
int BLACK = 8;
int NEAR_GOOD = 3;
int NEAR_BAD = -2;
int NEAR_EMPTY = 0;
int NEAR_BLACK = 1;
int TRIPLE = 2;
int HEIGHT_SCORE[] = {20,15,15,12,8,6,4,2,2,2,1,1,1,0,0,0};

struct Move
{
	char a,b;
	int pos; // 0..7
	int rotate; // 0..3
	Move(char a='1', char b='1'):a(a),b(b) { pos = rotate = 0;}
	bool valid()
	{
		if (pos < 0 || pos > 7)
			return false;
		if (rotate < 0 || rotate > 3)
			return false;
		if (pos == 0 && rotate == 2)
			return false;
		if (pos == 7 && rotate == 0)
			return false;
		return true;
	}
};

int turn = 0;
Move nowMove;
long long x0;
long long x1;



Move predict()
{
		//cerr << "nextMove" << endl;
	if (turn == 0)
		x1 = (x0* 17235617 + 4311271) % 87465851;
	return Move(x0%5+'1',x1%5+'1');
}

Move nextMove()
{
		//cerr << "nextMove" << endl;
	if (turn == 0)
		x1 = (x0* 17235617 + 4311271) % 87465851;
	nowMove = Move(x0%5+'1',x1%5+'1');
	x0 = (x1* 17235617 + 4311271) % 87465851;
	x1 = (x0* 17235617 + 4311271) % 87465851;
	turn ++;
	return nowMove;
}
const int dx[] = {-1,0,1,0};
const int dy[] = {0,1,0,-1};

struct Point
{
	int x,y;
	Point(int x= 0,int y = 0):x(x),y(y){}
};

bool was[H][W];

struct Map
{
	char arr[H][W+1];
	int last[W];
	bool lost;
	int bonus;
	int triples;
	Map()
	{
		triples = 0;
		lost = false;
		bonus = 0;
		for (int i = 0; i < H; i ++)
			for (int j =0 ; j < W; j ++)
				arr[i][j] = '.';
			for (int j =0 ; j < W; j ++)
				last[j] = H-1;
	}
	void Read()
	{
		lost = false;
		//cerr << "Read" << endl;
		for (int i = 0; i < H; i ++)
		{
			string s;
			cin >> s;
			for (int j = 0; j < W; j ++)
				arr[i][j] = s[j];
		}
		for (int j =0; j < W; j ++)
		{
			for (int i = H-1; i >= 0; i --)
			{
				if (arr[i][j] == '.')
				{
					last[j] = i;
					break;
				}
			}
		}
	}
	Point ApplyBall(char color, int pos)
	{
		//cerr << "Apply Ball" << endl;
		if (pos < 0 || pos >= W)
			throw 44242;
		if (last[pos] == H || last[pos] == -1)
		{
			lost = true;
			return Point(0,0);
		}
		Point p(last[pos],pos);
		arr[last[pos]--][pos] = color;
		return p;
	}
	

	int dfs(int x, int y, char c)
	{
		if (x < 0 || y <0 || x >= H || y >= W || was[x][y] || arr[x][y] != c)
			return 0;
		int ans = 1;
		was[x][y] = true;
		for (int i = 0; i < 4; i ++)
			ans += dfs(x+dx[i],y+dy[i],c);
		return ans;
	}

	void DeleteLavine(int x, int y, char c)
	{
		//cerr << "DeleteLavine" << endl;
		if (x < 0 || y <0 || x >= H || y >= W)
			return;
		if (arr[x][y] == '.')
			return;
		if (arr[x][y] == '*')
		{
			arr[x][y] = '.';
			return;
		}
		if (arr[x][y] != c)
			return;
		arr[x][y] = '.';
		for (int i = 0; i < 4; i ++)
			DeleteLavine(x+dx[i],y+dy[i],c);
	}
	void Shift()
	{
		//cerr << "Shift" << endl;
		for (int j =0; j < W; j ++)
		{
			int lasti = -1;
			for (int i = H-1; i >= 0; i --)
			{
				if (arr[i][j] == '.')
					lasti = i;
				else if (lasti != -1)
				{
					swap(arr[i][j],arr[lasti][j]);
					lasti --;
				}
			}
			last[j] = lasti;
		}
	}
	int Lavinate()
	{
		//cerr << "Lavinate" << endl;
		int lavine_cnt= 0;
		int balls_cnt =0;
		int lavine_length=0;
		while (true)
		{
			triples = 0;
			bool ok = false;
			memset(was,0,sizeof(was));

			for (int j = 0; j < W; j ++)
				for (int i = last[j]-1; i >= 0; i --)
				{
					if (was[i][j])
						continue;
					if (arr[i][j] == '.' || arr[i][j] == '*')
						continue;
					int s = dfs(i,j,arr[i][j]);
					if (s >= 4)
					{
						ok = true;
						lavine_cnt ++;
						balls_cnt += s;
						DeleteLavine(i,j,arr[i][j]);
					}
					if (s == 3)
						triples ++;
				}
			Shift();

			if (!ok)
				break;
			else
				lavine_length ++;
		}
		int score = balls_cnt - lavine_cnt - 2*lavine_length + MAGIC[lavine_length];
		return score;
	}
	bool Lost()
	{
		return lost;
	}
	pair<Point,Point> ApplyMove(const Move &m)
	{
		//cerr << "Apply Move" << endl;
		if (m.rotate == 1)
			return make_pair(ApplyBall(m.a,m.pos),ApplyBall(m.b,m.pos));
		if (m.rotate == 3)
			return make_pair(ApplyBall(m.b,m.pos),ApplyBall(m.a,m.pos));
		if (m.rotate == 0)
			return make_pair(ApplyBall(m.a,m.pos),ApplyBall(m.b,m.pos+1));
		if (m.rotate == 2)
			return make_pair(ApplyBall(m.a,m.pos),ApplyBall(m.b,m.pos-1));
	}
	int ScoreBallArtem(Point p)
	{
		//cerr << "ScoreBallArtem" << endl;
		int score = 0;
		score -= HEIGHT_SCORE[p.x];
		for (int i= 0; i < 4; i ++)
		{
			int x  = p.x+dx[i];
			int y  = p.y+dy[i];
			if (x < 0 || x >= H || y < 0 || y >= W)
			{
				score += NEAR_EMPTY;
				continue;
			}
			if (arr[x][y] =='.')
			{
				score += NEAR_EMPTY;
				continue;
			}
			if (arr[x][y] =='*')
			{
				score += NEAR_BLACK;
				continue;
			}
			if (arr[x][y] == arr[p.x][p.y])
				score += NEAR_GOOD;
			else
				score += NEAR_BAD;
		}
		return score;
	}
};

int Valuate(Map &m, const Move & move)
{
	pair <Point,Point> p = m.ApplyMove(move);
	int sc0=0;
	if (move.rotate%2 == 1)
		sc0 = -2;
	int sc1 = m.ScoreBallArtem(p.first);
	int sc2 = m.ScoreBallArtem(p.second);
	int black = m.Lavinate();
	if (m.Lost())
		return -1e9;
	int score = black*BLACK+sc1+sc2+sc0+m.triples/TRIPLE;
	return score;
}

Map me, tmp;
Map enemy;

int MakeAllDEPTH(const Map &me)
{
	Move m = predict();
	Move bestMove = m;
	int bestScore = -1e9;
	for (int i=  0; i < 8; i ++)
		for (int j = 0; j < 4; j ++)
		{
			m.pos = i;
			m.rotate = j;
			if (!m.valid())
				continue;
			tmp = me;
			int s = Valuate(tmp,m);
			if (s > bestScore)
			{
				bestScore = s;
				bestMove = m;
			}
		}
	return bestScore;
}

Move MakeAll()
{

	me.Read();
	enemy.Read();
	Move m = nextMove();
	Move bestMove = m;
	int bestScore = -1e9;
	for (int i=  0; i < 8; i ++)
		for (int j = 0; j < 4; j ++)
		{
			m.pos = i;
			m.rotate = j;
			if (!m.valid())
				continue;
			tmp = me;
			int s = Valuate(tmp,m) + MakeAllDEPTH(tmp)/SECOND_LEVEL;
			if (s > bestScore)
			{
				bestScore = s;
				bestMove = m;
			}
		}
	return bestMove;
}

int main(int argc, char* argv[])
{
	//if (argc > 1)
	//	freopen(argv[1], "w", stderr);
	for(int i = 0 ; ; ++i)
	{
		char str[100];
		scanf("%s",str);
		if(!strcmp(str,"Quit"))
		  break;
		if(!strcmp(str,"Start")) {
			scanf("%d", &x0);
			printf("GuinnessBotALCO\n");
			fflush(stdout);
		}
		else if(!strcmp(str,"Move")) {
			Move m = MakeAll();
			//cerr << m.pos << " " << m.rotate << endl;
			if (m.rotate == 2)
				m.pos --;
			printf("%d %d\n", m.pos, m.rotate);
			fflush(stdout);
		}
	}

	return 0;
}
