#pragma comment(linker,"/STACK:64000000")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <ctime>

using namespace std;

#define FOR(i,a,b)  for (int i = (a);i<=(b);i++)
#define DFOR(i,b,a) for (int i = (b);i>=(a);i--)
#define SZ(a)       ((int)a.size())
#define FA(i,v)     FOR(i,0,SZ(v)-1)
#define RFA(i,v)    DFOR(i,SZ(v)-1,0)
#define CLR(a)      memset(a,0,sizeof(a))

#define FI first
#define SE second
#define RE scanf
#define WR printf
#define PB push_back
#define MP make_pair

#define o_O 1000000000
#define LL long long

#define PAR pair<int,int>
#define VI vector<int>

void _die(int a) {
#ifndef ONLINE_JUDGE
	exit(1);
#else
	printf("%d",a/(a+a));
#endif
}
void _never(int a) {printf("OPS:%4d\n",a);fprintf(stderr,"OPS:%4d\n",a);}
#define ass(f) {if (!(f)) {_never(__LINE__);cout.flush();cerr.flush();_die(0);}}

bool F[16][8];
//bool F2[16][8];
int cnt=0;
int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };

struct STATE {
	char m[16][8];
	STATE()
	{
		FOR(a,0,15) FOR(b,0,7) m[a][b] = '.';
	}
	void dfs(int x, int y, char ch)
	{
		F[x][y]=true;
		cnt++;
		FOR(a,0,3)
		{
			int xx = x+dx[a];
			int yy = y+dy[a];
			if (0<=xx && xx<=15 && 0<=yy && yy<=7)
				if (!F[xx][yy])
					if (m[xx][yy]==ch)
						dfs(xx,yy,ch);
		}
	}
	void fill(int x, int y, char ch)
	{
		//F2[x][y]=true;
		m[x][y]='.';
		FOR(a,0,3)
		{
			int xx = x + dx[a];
			int yy = y + dy[a];
			if (0<=xx && xx<=15 && 0<=yy && yy<=7)
			{
				if (m[xx][yy]=='*') m[xx][yy]='.';
				if (m[xx][yy]==ch)
					//if (!F2[xx][yy])
					fill(xx,yy,ch);
			}
		}
	}
	bool Can(int s, int r, PAR b) {
		if (!(0<=s && s<=7)) return false;
		if (!(0<=r && r<=3)) return false;
		if (s==7 && r%2==0) return false;
		if (r%2==0) // oo
		{
			if (m[0][s]!='.' || m[0][s+1]!='.') return false;
		}
		else // 8
		{
			if (m[0][s]!='.' || m[1][s]!='.') return false;
		}
		return true;
	}
	int Move(int s, int r, PAR b)
	{
		ass(Can(s,r,b));
		int stage=0;
		int re=0;

		if (r%2==0) // oo
		{
			DFOR(a,15,0) if (m[a][s]=='.')
			{
				m[a][s]=(r==0 ? b.first+'0' : b.second+'0');
				break;
			}
			DFOR(a,15,0) if (m[a][s+1]=='.')
			{
				m[a][s+1]=(r==0 ? b.second+'0' : b.first+'0');
				break;
			}
		}
		else
		{
			DFOR(a,15,0) if (m[a][s]=='.')
			{
				m[a][s]=(r==1 ? b.second+'0' : b.first+'0');
				m[a-1][s]=(r==1 ? b.first+'0' : b.second+'0');
				break;
			}
		}

		while(1)
		{
			//wr();
			int areas=0;
			int balls=0;
			CLR(F);
			FOR(a,0,15) FOR(b,0,7) if (m[a][b]!='.' && m[a][b]!='*') if (!F[a][b])
			{
				cnt = 0;
				dfs(a,b,m[a][b]);
				if (cnt >= 4)
				{
					fill(a,b,m[a][b]);
					areas++;
					balls+=cnt;
				}
			}
			if (areas == 0) break;
			re += balls-areas-2;
			FOR(a,0,7)
			{
				int i=15;
				DFOR(b,15,0)
					if (m[b][a]!='.')
					{
						swap(m[b][a], m[i][a]);
						i--;
					}
			}
			stage++;
		}

		if (stage == 2) re+=3;
		else if (stage == 3) re+=6;
		else if (stage == 4) re+=12;
		else if (stage == 5) re+=24;
		else if (stage == 6) re+=50;
		else if (stage >= 7) re+=100;

		return re;
	}
	int get_h()
	{
		int re=0;
		FOR(a,0,7) FOR(b,0,15) if (m[b][a]!='.')
		{
			re += (16-b)*(16-b);
			break;
		}
		return re;
	}
	void wr()
	{
		FOR(a,0,15)
		{
			FOR(b,0,7) WR("%c", m[a][b]);
			WR("\n");
		}
		WR("\n");
	}
	void init_by(STATE & s)
	{
		FOR(a,0,15) FOR(b,0,7) m[a][b] = s.m[a][b];
	}
};

LL x0;
vector<LL> x;
vector<PAR> blls;
int cur_move;

void next() {
	FOR(i,0,1) x.PB(SZ(x) ? (x.back() * 17235617 + 4311271) % 87465851 : (LL)x0);
	blls.push_back(MP((int)x[SZ(x)-2] % 5 + 1,(int)x[SZ(x)-1] % 5 + 1));
}
void sol1()
{
	STATE sta;
	char ch[20];
	FOR(a,0,15)
	{
		RE("%s", ch);
		FOR(b,0,7) sta.m[a][b]=ch[b];
	}
	int r, s, i, j;
	RE("%d%d%d%d", &s, &r, &i, &j);
	int score = sta.Move(s,r,MP(i,j));

	WR("%d\n", score);
	sta.wr();
}

#define MAXDEEP 3

int best=-1, best_s=0, best_r=0;
int cur_s, cur_r;

void g_dfs(STATE & s, int cost, int deep)
{
	if (deep == MAXDEEP)
	{
		cost = cost*2500 + 2500-s.get_h();
		if (cost > best)
		{
			best = cost;
			best_s = cur_s;
			best_r = cur_r;
		}
		return;
	}

	FOR(a,0,7) FOR(b,0,3) if (s.Can(a,b,blls[cur_move+deep]))
	{
		STATE s2;
		s2.init_by(s);
		int re = s2.Move(a,b,blls[cur_move+deep]);
		if (deep==0)
		{
			cur_s = a;
			cur_r = b;
		}
		g_dfs(s2,cost+re,deep+1);
	}
}

void sol()
{
	STATE me, enemy;
	char ch[20];
	FOR(a,0,15)
	{
		RE("%s", ch);
		FOR(b,0,7) me.m[a][b]=ch[b];
	}
	FOR(a,0,15)
	{
		RE("%s", ch);
		FOR(b,0,7) enemy.m[a][b]=ch[b];
	}

	/*int best=-1, best_s=2, best_r=1;
	PAR balls = blls[cur_move];
	FOR(a,0,7) FOR(b,0,3) if (me.Can(a,b,balls))
	{
		STATE me2;
		me2.init_by(me);
		int re = me2.Move(a,b,balls);
		re = re*2050 + 2050-me2.get_h();
		if (re > best)
		{
			best = re;
			best_s = a;
			best_r = b;
		}
	}*/

	best = -1;
	best_s = 0;
	best_r = 0;
	g_dfs(me, 0, 0);

	WR("%d %d\n", best_s, best_r);
}
int main()
{
#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
	//sol1();
	//return 0;
	int w = 8, h = 16, x0;
	cur_move=0;
	for(int i = 0 ; ; ++i)
	{
		char str[100];
		scanf("%s",str);
		if(!strcmp(str,"Quit"))
		  break;
		if(!strcmp(str,"Start")) {
			scanf("%d", &x0);
			::x0 = x0;
			FOR(a,1,10) next();
			printf("TurtleCommanderBot05\n");
			fflush(stdout);
		}
		else if(!strcmp(str,"Move")) {
			next();
			sol();
			cur_move++;
			//for(int j = 0; j < 2 * h; j++)
			//	scanf("%*s");
			//printf("%d %d\n", i % w, 1);
			fflush(stdout);
		}
	}

	return 0;
}
