#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
#include <cmath>

using namespace std;

long long w = 8, h = 16;
long long x0, x1;
char a[2][30][30];
long long b[]={0,0,30,100,150,500,1200,2500,60000,70000,80000};
//long long b[]={0,0,30,59,200,500,500,500,600,700,800};
long long bcnt=11;
char aa[30][30];

void push(long long x, char cl){
	long long i=0;
	while (i<h && aa[i][x]=='.'){
		i++;
	}
	i--;
	aa[i][x]=cl;
	return;
}

long long dx[]={0,1,-1,0};
long long dy[]={1,0,0,-1};

bool isxyvalid(long long x, long long y){
	if (0<=x && x<h && 0<=y && y<w) return 1;
	return 0;
}

long long calcpoints(){
	long long ans=0;
	bool bb[30][30];
	memset(bb,0,sizeof(bb));
	queue <pair<long long,long long>> q;
	for (long long i=0;i<h;i++){
		for (long long j=0;j<w;j++){
			if (!bb[i][j] && aa[i][j]!='.' && aa[i][j]!='*'){
				q.push(make_pair(i,j));
				bb[i][j]=1;
				long long c=1;
				long long x,y;
				while (!q.empty()){
					x=q.front().first;
					y=q.front().second;
					q.pop();
					for (long long k=0;k<4;k++){
						x+=dx[k]; y+=dy[k];
						if (isxyvalid(x,y) && !bb[x][y] && aa[x][y]==aa[i][j]){
							bb[x][y]=1;
							c++;
							q.push(make_pair(x,y));
						}
						x-=dx[k]; y-=dy[k];
					}
				}
				if (c>=bcnt) c=bcnt-1;
				ans+=b[c];
			}
		}
	}
	return ans;
}

bool ispos;

long long calc(long long x, long long key, char cl1, char cl2){
	for (long long i=0;i<h;i++){
		for (long long j=0;j<w;j++){
			aa[i][j]=a[0][i][j];
		}
	}
	if ((key==0 && x<w-1 && (aa[0][x]!='.' || aa[0][x+1]!='.')) || (key==2 && x>0 && (aa[0][x]!='.' || aa[0][x-1]!='.')) 
		|| (key%2==1 && aa[1][x]!='.') || (key==0 && x==w-1) || (key==2 && x==0)){
		ispos=0;
		return -1000000000;
	}
	long long a1=calcpoints();
	if (key==0){
		push(x, cl1);
		push(x+1, cl2);
	}else	
	if (key==1){
		push(x, cl2);
		push(x, cl1);
	}else	
	if (key==2){
		push(x, cl1);
		push(x-1, cl2);
	}else{
		push(x, cl1);
		push(x, cl2);
	}
	long long a2=calcpoints();
	ispos=1;
	return a2-a1;
}

int main()
{
	//FILE *logg;
	//logg=fopen("log.txt","wt");
	//freopen("log.txt","rt",stdin);
	for(long long step = 0 ; ; ++step)
	{
		char str[100];
		scanf("%s",str);
		if(!strcmp(str,"Quit")){
			//fprintf(logg,"%s\n",str);
		  break;
		}
		if(!strcmp(str,"Start")) {
			//fprintf(logg,"%s\n",str);
			scanf("%lld", &x0);
			//fprintf(logg,"%lld\n",x0);
			printf("Team13\n");
			fflush(stdout);
		}
		else if(!strcmp(str,"Move")) {
			//fprintf(logg,"%s\n",str);
			for(long long i = 0; i < h; i++){
				scanf("%s",a[0][i]);
				//fprintf(logg,"%s\n",a[0][i]);
			}
			for(long long i = 0; i < h; i++){
				scanf("%s",a[1][i]);
				//fprintf(logg,"%s\n",a[1][i]);
			}
			long long bx=0,bp=0,bans=-1000000000,bt;
			x1=(17235617*x0+4311271)%87465851;
			for (long long x=0;x<w;x++){
				for (long long p=0;p<4;p++){
					bt=calc(x,p,'0'+x0%5 + 1,'0'+x1%5 + 1);
					if (ispos && bt>bans){
						bx=x;
						bp=p;
						bans=bt;
					}
				}
			}
			x0=(17235617*x1+4311271)%87465851;
			while ((bx==7 && bp==0) || (bx==0 && bp==2) || bp>3 || bp<0 || bx<0 || bx>7){
				bx=rand()%8;
				bp=rand()%4;
			}
			//fprintf(logg,"%d %d\n", ((int)bx), ((int)bp));
			//fflush(logg);
			printf("%d %d\n", ((int)bx), ((int)bp));
			fflush(stdout);
		}
	}
	return 0;
}
