/*------------------------------------------------------------
TEAM22
A
239
Target: MSVC9; Platform: Win32; Comment: MS Visual C++ 9
------------------------------------------------------------*/
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <ctime>

using namespace std;

char cmd[100];
template<class T> T sqr(const T& x) {
	return x * x;
}

#ifdef pperm
	FILE *flog = fopen("log.txt", "w");
#endif

#define n 8
enum EColor {
	empty = 0,
	white = 1,
	black = 2
};
EColor we;
EColor field[8][8];
int	ncolors[3];
int nrcolors[8][3];
int nccolors[8][3];
int st = 0;
typedef double TValue;
const TValue max_value = 1e100, min_value = -1e100;

struct SRes {
	int r, c, r2, c2;

	TValue value;
} res;
int di[3][3] = {{}, {1, 1, 1}, {-1, -1, -1}};
int dj[3][3] = {{}, {-1, 0, 1}, {-1, 0, 1}};

void EMove(char *s) {
	char c1, c2;
	int d1, d2;
	sscanf(s, "%c%d%c%d", &c1, &d1, &c2, &d2);
	d1 --;
	d2 --;
	c1 -= 'a';
	c2 -= 'a';
	nrcolors[d2][field[d2][c2]]--;
	nrcolors[d1][field[d1][c1]]--;

	nccolors[c2][field[d2][c2]]--;
	nccolors[c1][field[d1][c1]]--;

	ncolors[field[d2][c2]]--;
	ncolors[empty]++;
	field[d2][c2] = field[d1][c1];
	field[d1][c1] = empty;

	nrcolors[d2][field[d2][c2]]++;
	nrcolors[d1][field[d1][c1]]++;

	nccolors[c2][field[d2][c2]]++;
	nccolors[c1][field[d1][c1]]++;

}
void EMove(int r1, int c1, int r2, int c2) {
	nrcolors[r2][field[r2][c2]]--;
	nrcolors[r1][field[r1][c1]]--;

	nccolors[c2][field[r2][c2]]--;
	nccolors[c1][field[r1][c1]]--;

	ncolors[field[r2][c2]]--;
	ncolors[empty]++;
	field[r2][c2] = field[r1][c1];
	field[r1][c1] = empty;

	nrcolors[r2][field[r2][c2]]++;
	nrcolors[r1][field[r1][c1]]++;

	nccolors[c2][field[r2][c2]]++;
	nccolors[c1][field[r1][c1]]++;
}

TValue value_of_state() {
	if (nrcolors[0][black]) {
		if (we == black) {
			return max_value;
		} else {
			return min_value;
		}
	}
	if (nrcolors[7][white]) {
		if (we == white) {
			return max_value;
		} else {
			return min_value;
		}
	}
	TValue val = (ncolors[we] - ncolors[we == white? black : white]) * 200 + ncolors[we] * 1e-4;
	for (int i = 0; i < 8; i++) {
		if (we == white) {
			val += nrcolors[i][white] * sqr(i) * 1e-1;
			val -= nrcolors[i][black] * sqr(7 - i) * 1e-1 * (black == we? 1 : 1.1);
		} else {
			val -= nrcolors[i][white] * sqr(i) * 1e-1;
			val += nrcolors[i][black] * sqr(7 - i) * 1e-1 * (black == we? 1 : 1.1);

		}
	}
	/*double mw = 0.0, mb = 0.0, ww = 0.01, wb = 0.01;
	for (int i = 0; i < 8; i++) {
		ww += sqr(nccolors[i][white]);
		wb += sqr(nccolors[i][black]);
		mw += sqr(nccolors[i][white]) * i;
		mb += sqr(nccolors[i][black]) * i;
	}
	mw /= ww;
	mb /= wb;*/
	return val ;//+ fabs(mw - mb) / (ncolors[white] + ncolors[black]);
}

bool InField(int r, int c) {
	return r >= 0 && c >= 0 && r < n && c < n;
}
void Move(EColor col, int h, bool f = 0) {
	if (clock() - st > CLOCKS_PER_SEC * 2) {
		res.value = value_of_state();
		return;
	}
	if (h == 0) {
		res.value = value_of_state();
		return;
	}
	double v = value_of_state();
	if (fabs(v) > 1e99) {
		res.value = v;
		return;
	}
	SRes best;
	bool iswe = col == we;
	best.value = (iswe? min_value: max_value);
	int cbest = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (field[i][j] == col) {
				for (int d = 0; d < 3; d++) {
					int r = i + di[col][d], c = j + dj[col][d];
					if (InField(r, c) && field[r][c] != col) {
						if (dj[col][d] == 0 && field[r][c] != empty) continue;
						EColor c1 = field[i][j], c2 = field[r][c];

						nrcolors[i][c1]--;
						nrcolors[r][c2]--;
						nrcolors[i][empty]++;
						nrcolors[r][c1]++;

						nccolors[j][c1]--;
						nccolors[c][c2]--;
						nccolors[j][empty]++;
						nccolors[c][c1]++;

						ncolors[c2]--;
						ncolors[empty]++;
						field[i][j] = empty;
						field[r][c] = c1;
						if (f && (col == white && i >= 5 || col == black && i <= 2)) {
							Move(col == white? black : white, h);
						} else {
							Move(col == white? black : white, h - 1);
						}
						res.value = res.value * 0.01 + value_of_state();
						if (!cbest || iswe && res.value > best.value || !iswe && res.value < best.value) {
							cbest = 1;
							best.value = res.value;
							best.r = i;
							best.c = j;
							best.r2 = r;
							best.c2 = c;
						} else if (res.value == best.value) {
							cbest++;
							if (rand() % cbest == 0) {
								best.r = i;
								best.c = j;
								best.r2 = r;
								best.c2 = c;
							}
						}
						field[i][j] = c1;
						field[r][c] = c2;
						ncolors[c2]++;
						ncolors[empty]--;

						nrcolors[i][c1]++;
						nrcolors[r][c2]++;
						nrcolors[i][empty]--;
						nrcolors[r][c1]--;

						nccolors[j][c1]++;
						nccolors[c][c2]++;
						nccolors[j][empty]--;
						nccolors[c][c1]--;

					}
				}
			}
		}
	}
	res = best;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	srand(time(0));

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 8; j++) {
			field[i][j] = white;
			field[i + 6][j] = black;
		}
	}
	ncolors[white] = 16;
	ncolors[black] = 16;
	nrcolors[0][white] = 8;
	nrcolors[1][white] = 8;
	nrcolors[7][black] = 8;
	nrcolors[6][black] = 8;
	for (int i = 0; i < 8; i++) {
		nccolors[i][white] = nccolors[i][black] = 2;
		nccolors[i][empty] = 4;
	}
	scanf("%s", cmd);
	printf("Pekuchu_v1.2\n");
	fflush(stdout);

	scanf("%s", cmd);
	if (cmd[0] == 'S') {
		we = white;
		goto skip2;
	} else {
		we = black;
		goto skip;
	}
	while(1) {
		scanf("%s", cmd);
		if (cmd[0] == 'Q') {
			break;
		}
skip:   EMove(cmd);
skip2:	
		int cm = ncolors[white] + ncolors[black];
		//int g = (int)(min(max(log(1048576.0) / log(0. + cm), 5.0), 20.0) + 0.1);
		//int g = 5;
		/*if (we == black) {
			g -= (g & 1);
		} else {*/
			//if (!(g & 1)) g--;
		//}
		st = clock();
		Move(we, 4, 1);
		EMove(res.r, res.c, res.r2, res.c2);
		printf("%c%d%c%d\n", res.c+'a', res.r + 1, res.c2 + 'a', res.r2 + 1);
		fflush(stdout);
	}
	return 0;
}
