#include <cstdio>
#include <cstring>
#include <stdlib.h>

int w = 8, h = 16;
long long x0, x1;

char my[500], alien[500];
char buf[500];

void init_field(char* arr){
	for (int i = 0; i < h; ++i)
		scanf("%s", arr + i * w);
}

long long next(long long x){
	return (x * 17235617 + 4311271) % 87465851;
}


int test(int i, int j){
	if ((i < h) && (0 <= i) && (j < w) && (0 <= j))
		return 1;
	return 0;
}

void dfs(int color, int i, int j, int& kol){
	buf[i * w + j] = 1;
	++kol;
	if (test(i-1, j) && (color + '0' == *(my + (i-1) * w + j)) && !buf[(i-1) * w + j])
		dfs(color, i-1, j, kol);
	if (test(i+1, j) && (color + '0' == *(my + (i+1) * w + j)) && !buf[(i+1) * w + j])
		dfs(color, i+1, j, kol);
	if (test(i, j+1) && (color + '0' == *(my + i * w + j + 1)) && !buf[i * w + j+1])
		dfs(color, i, j+1, kol);
	if (test(i, j-1) && (color + '0' == *(my + i * w + j - 1)) && !buf[i * w + j-1])
		dfs(color, i, j-1, kol);
}

int find_max_smezh_amount(int color, int x, int y){
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			*(buf + i*w + j) = 0;
	int res = 0;
	dfs(color, x, y, res);
	return res;
}

void analysis(int & x, int & y, int& col){
	x = 15; y = rand()%w; col = 1;
	int res = 0;
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			if (*(my + i * w + j) == '.' && ((i + 2) >= h || *(my + (i+1) * w + j) != '.' || *(my + (i+2) * w + j) != '.') ){
				int buf;
				buf = find_max_smezh_amount(x0 % 5 + 1, i, j);
				if (res < buf || (res == buf  && x  < i)){
					x = i;
					y = j;
					col = x0 % 5 + 1;
					res = buf;
				}
				buf = find_max_smezh_amount(x1 % 5 + 1, i, j);
				if (res < buf || (res == buf  && x  < i)){
					x = i;
					y = j;
					col = x1 % 5 + 1;
					res = buf;
				}
			}
}

void print_res(){
	int x, y, col;
	analysis(x, y, col);
	if (col == x0 % 5 + 1){
		if (*(my + (x+1)*w + y) == '.'){
			printf("%d %d\n", y, 1);
		} else {
			printf("%d %d\n", y, 3);
		}
	} else {
		if (*(my + (x+1)*w + y) == '.'){
			printf("%d %d\n", y, 3);
		} else {
			printf("%d %d\n", y, 1);
		}
	}
	x0 = next(x1);
	x1 = next(x0);
}

int main()
{
 //   freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	for(int i = 0 ; ; ++i)
	{
		char str[100];
		scanf("%s",str);
		if(!strcmp(str,"Quit"))
		  break;
		if(!strcmp(str,"Start")) {
			scanf("%lld", &x0);
			x1 = next(x0);
			printf("kodomo\n");
			fflush(stdout);
		}
		else if(!strcmp(str,"Move")) {
			init_field(my);
			scanf("\n");
			init_field(alien);
			print_res();
			fflush(stdout);
		}
	}

	return 0;
}
