#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <sstream>

#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()

using namespace std;

typedef pair<int, int> ii;
typedef long long int64;
typedef vector<int> vi;
typedef long long ll;

template<class T> T abs(T x) { return x > 0 ? x : -x; }
template<class T> T sqr(T x) { return x * x; }

const int w = 8;
const int h = 16;

const int BONUS[] = {0, 0, 3, 612, 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, 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, 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, 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, 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, 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, 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, 100, 100, 100, 100};
const int inf = 1000 * 1000 * 100;

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

vi ballsSequence;

int moveNumber;

#ifndef PODBOR

const int SCORE_THREE_LOCKED = 0;
const int SCORE_TWO_LOCKED = 0;
const int SCORE_THREE_FREE = 11;
const int SCORE_TWO_FREE = 7;
const int SCORE_BLACK = -2;
const int SCORE_MOVE = 6;
const int SCORE_BALL = -2;
const int SCORE_ATTACK = 6;

const int ATTACK_DANGER = 6;

void init() {
	
}
#else

int SCORE_THREE_LOCKED = 8;
int SCORE_TWO_LOCKED = 4;
int SCORE_THREE_FREE = 11;
int SCORE_TWO_FREE = 7;
int SCORE_BLACK = -2;
int SCORE_MOVE = 6;
int SCORE_BALL = -6;
int SCORE_ATTACK = 6;

int ATTACK_DANGER = 8;

void init() {
	FILE* f = fopen("config2.txt", "r");
	fscanf(f, "%d%d%d%d%d%d%d%d%d", &SCORE_THREE_LOCKED, &SCORE_TWO_LOCKED, &SCORE_THREE_FREE, &SCORE_TWO_FREE, &SCORE_BLACK, &SCORE_MOVE, &SCORE_BALL, &SCORE_ATTACK, &ATTACK_DANGER);
}

#endif

const int DEPTH = 1;


void genSequence(int64 x0) {
	for (int it = 0; it < 100000; ++it) {
		ballsSequence.pb((int) x0);
		x0 = (x0 * 17235617LL + 4311271LL) % 87465851LL;
	}
}



class Field {
public:
	Field() {}

	void read() {
		for (int i = 0; i < h; ++i) {
			string s;
			cin >> s;
			for (int j = 0; j < w; ++j)
				a[i][j] = s[j];
		}
	}

	char* operator[](int ind) {
		return a[ind];
	}

	bool drop(int x, int color) {
//		cerr << "drop " << x << ", " << color << "\n"; cerr.flush();
		int cur = 0;
		while (cur < h && a[cur][x] == '.') ++cur;
		if (cur == 0) {
//			cerr << "bad end of drop\n";cerr.flush();
			return false;
		}
		a[cur - 1][x] = color + '0'; 
//		cerr << "good end of drop\n";cerr.flush();
		return true;
	}

	int avalanche() {
		memset(marks, 0, sizeof(marks));
		int curArea = 1;
		vi counts;
		counts.pb(0);
		for (int i = 0; i < h; ++i)
			for (int j = 0; j < w; ++j)
				if (isdigit(a[i][j]) && marks[i][j] == 0)
					counts.pb(dfs(i, j, curArea++));
		int res = 0;
		for (int i = 0; i < h; ++i)
			for (int j = 0; j < w; ++j) {
				if (a[i][j] == '*') {
					for (int dir = 0; dir < 4; ++dir) {
						int x = i + dx[dir];
						int y = j + dy[dir];
						if (x >= 0 && x < h && y >= 0 && y < w && counts[marks[x][y]] > 3) {
							a[i][j] = '.';
							break;
						}
					}
				} else {
					if (counts[marks[i][j]] > 3)
						a[i][j] = '.';
				}
			}
		for (int i = 0; i < sz(counts); ++i)
			if (counts[i] > 3)
				res += counts[i] - 1;
		if (res != 0)
			res -= 2;
		dropAll();
		return res;
	}

	void print() {
		return;
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j)
				fprintf(stderr, "%c", a[i][j]);
			fprintf(stderr, "\n");
		}
		fprintf(stderr, "\n");
		fflush(stderr);
	}

	int evaluate(int nextMove) {
		int res = 0;

		memset(marks, 0, sizeof(marks));
		int curArea = 1;
		vi counts;
		counts.pb(0);
		for (int i = 0; i < h; ++i)
			for (int j = 0; j < w; ++j)
				if (isdigit(a[i][j]) && marks[i][j] == 0)
					counts.pb(dfs(i, j, curArea++));

		vi freedom(sz(counts), 0);
		for (int i = 0; i < h; ++i)
			for (int j = 0; j < w; ++j) {
				if (marks[i][j] != '.')
					res += SCORE_BALL;
				if (marks[i][j] == '*')
					res += SCORE_BLACK;
				if (marks[i][j] != 0 && freedom[marks[i][j]] == 0) {
					for (int dir = 0; dir < 4; ++dir) {
						int x = i + dx[dir];
						int y = j + dy[dir];
						if (x >= 0 && x < h && y >= 0 && y < w && a[x][y] == '.') {
							freedom[marks[i][j]] = 1;
						}
					}
				}
			}
		for (int i = 0; i < sz(counts); ++i) {
			if (counts[i] == 2) {
				if (freedom[i])
					res += SCORE_TWO_FREE;
				else
					res += SCORE_TWO_LOCKED;
			}
			if (counts[i] == 3) {
				if (freedom[i]) {
					res += SCORE_THREE_FREE;
				}
				else
					res += SCORE_THREE_LOCKED;
			}
		}

		return res;
	}

private:
	char a[h][w];
	
	int marks[h][w];

	int dfs(int x, int y, int mark) {
		marks[x][y] = mark;
		int res = 1;
		for (int dir = 0; dir < 4; ++dir) {
			int _x = x + dx[dir], _y = y + dy[dir];
			if (_x < 0 || _y < 0 || _x >= h || _y >= w) continue;
			if (marks[_x][_y] != 0) continue;
			if (a[_x][_y] != a[x][y]) continue;
			res += dfs(_x, _y, mark);
		}
		return res;
	}

	void dropAll() {
		for (int j = 0; j < w; ++j) {
			int cur = h - 1;
			for (int i = h - 1; i >= 0; --i) {
				if (a[i][j] != '.')
					a[cur--][j] = a[i][j];
			}
			while (cur >= 0)
				a[cur--][j] = '.';
		}
	}
};

pair<Field, int> makeMove(Field f, ii move, int num) {
	if (move.first == 7 && move.second % 2 == 0)
		return mp(f, -inf);
	int black = 0;

	int color1 = ballsSequence[num * 2] % 5 + 1;
	int color2 = ballsSequence[num * 2 + 1] % 5 + 1;
	int x1, x2;
	if (move.second < 2) {
		x1 = move.first;
		if (move.second == 1)
			x2 = move.first;
		else
			x2 = move.first + 1;
	} else {
		x2 = move.first;
		if (move.second == 3) {
			x1 = move.first;
			swap(color1, color2);
		} else 
			x1 = move.first + 1;
	}

	if (!f.drop(x2, color2)) return mp(f, -inf);
	if (!f.drop(x1, color1)) return mp(f, -inf);

	int cntAv = 0;

	while (1) {
		int cur = f.avalanche();
		if (!cur) break;
		black += cur;
		++cntAv;
	}

	black += BONUS[cntAv];

	return mp(f, black);
}

int evaluateAttackScore(int black, Field& f) {
	/*int empty = 0;
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			if (f[i][j] == '.')
				++empty;
	if (empty > h * w / 2)
		return black * black * SCORE_ATTACK;
	else*/
		return black * SCORE_ATTACK;
}

int evaluateDfs(Field& f, int moveNum, int left) {
	if (left <= 0)
		return f.evaluate(moveNum);
	int res = -inf;
	for (int x = 0; x < w; ++x) 
		for (int j = 0; j < 4; ++j) {
			pair<Field, int> next = makeMove(f, ii(x, j), moveNum);
			if (next.second == -inf) continue;
			int curScore = evaluateDfs(next.first, moveNum + 1, left - 1);
			curScore += evaluateAttackScore(next.second, f);
			res = max(res, curScore);
		}
	if (res == -inf) res = f.evaluate(moveNum);
	return res;
}

int maxFall(Field f, int moveNum) {
	int res = -inf;
	for (int x = 0; x < w; ++x) 
		for (int j = 0; j < 4; ++j) {
			pair<Field, int> next = makeMove(f, ii(x, j), moveNum);
			int cur = next.second;
			res = max(res, cur);
		}
	return res;
}

ii solve(Field f_ours, Field f_his) {
	ii bestMove(0, 0);
	int bestValue = -inf;
	int enemyAttack = maxFall(f_his, moveNumber);
	for (int x = 0; x < w; ++x) 
		for (int j = 0; j < 4; ++j) {
			//cerr << "trying move " << x << ", "  << j << "\n"; cerr.flush();
			pair<Field, int> next = makeMove(f_ours, ii(x, j), moveNumber);
			int newDepth = DEPTH;
			if (enemyAttack > ATTACK_DANGER) 
				newDepth = 0;
			if (next.second == -inf) continue;
			int curValue = evaluateDfs(next.first, moveNumber + 1, newDepth) + evaluateAttackScore(next.second, f_ours);
			if (curValue == -inf) continue;
			if (curValue > bestValue || curValue == bestValue && rand() % 26 == 0)
				bestValue = curValue, bestMove = ii(x, j);
		}
	//cerr << "Best value = " << bestValue << "\n";
	makeMove(f_ours, bestMove, moveNumber).first.print();
	return bestMove;
}

int main() {

	//freopen("log.txt", "w", stderr);

	for (moveNumber = 0; ;) {
		init();
		char str[100];
		scanf("%s",str);
		if(!strcmp(str,"Quit"))
		  break;
		if(!strcmp(str,"Start")) {
			int x0;
			scanf("%d", &x0);
			genSequence(x0);
			printf("Unpredictable bot\n");
			fflush(stdout);
		}
		else if(!strcmp(str,"Move")) {
			Field f_ours, f_his;
			f_ours.read();
			f_his.read();

			f_ours.print();
			f_his.print();
//			fprintf(stderr, "--------------------------\n");
//			fflush(stderr);

			ii move = solve(f_ours, f_his);
			printf("%d %d\n", move.first, move.second);
			fflush(stdout);
			++moveNumber;
		}
	}
	return 0;
}
