/*------------------------------------------------------------
TEAM47
A
230
Target: MSVC9; Platform: Win32; Comment: MS Visual C++ 9
------------------------------------------------------------*/
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <stack>
#include <algorithm>

using namespace std;

#define SIZE 8

const int EMPTY = 0;
const int WHITE = 1;
const int BLACK = 2;
typedef int Figure;

void plog(string s)
{
	cerr << s << endl;
}

struct Ceil
{
	int col, row;

	Ceil(int r = 0, int c = 0) : col(c), row(r) {}

	bool valid()
	{
		return (col >= 0 && col < SIZE && row >= 0 && row < SIZE);
	}

	string toString()
	{
		string first = ""; first += ('a' + col);
		string second = ""; second += ('1' + row);		
		return first + second;
	}
};

typedef int Type;
const Type FRONT = 1;
const Type KILL = 2;

struct Move
{
	Ceil from, to;

	Move(int fromrow = 0, int fromcol = 0, int torow = 0, int tocol = 0)
	{
		from = Ceil(fromrow, fromcol);
		to = Ceil(torow, tocol);
	}

	string toString()
	{
		string res = from.toString() + to.toString();
		return res;
	}

	Figure getColor()
	{
		if (from.row - to.row < 0) return WHITE;
		return BLACK;
	}
};

const int INF = (1 << 30);

int Finish[3] = {-1, SIZE-1, 0};
int q[1000000],curr,time;

struct Game
{
	Figure** field;

	Figure our;
	stack<pair<Move, Figure>> history;

	Game()
	{
		our = EMPTY;
		field = new Figure*[SIZE];
		for (int row = 0; row < SIZE; ++row)
		{
			field[row] = new Figure[SIZE];
			for (int col = 0; col < SIZE; ++col)
			{
				if (row <= 1)
					field[row][col] = WHITE;
				else if (row >= 6)
					field[row][col] = BLACK;
				else
					field[row][col] = EMPTY;
			}
		}
	}

	Move move(Move m)
	{
		if (field[m.from.row][m.from.col] == EMPTY)
		{
			plog("Attempt go from empty ceil: " + m.toString());
			return Move();
		}
		history.push(make_pair(m, field[m.to.row][m.to.col]));
		field[m.to.row][m.to.col] = field[m.from.row][m.from.col];
		field[m.from.row][m.from.col] = EMPTY;

		return m;
	}

	void unMove()
	{
		if (history.empty())
		{
			plog("Attempt exctract move from empty stack");
			return;
		}
		pair<Move, Figure> last = history.top();
		history.pop();
		field[last.first.from.row][last.first.from.col] = field[last.first.to.row][last.first.to.col];
		field[last.first.to.row][last.first.to.col] = last.second;		
	}

	void clearHistory()
	{
		while (! history.empty())
			history.pop();
	}

	bool canMove(Figure color, Move move)
	{
		if (!move.from.valid() || !move.to.valid())
			return false;
		if (move.to.col == move.from.col)
			return field[move.to.row][move.to.col] == EMPTY;
		return field[move.to.row][move.to.col] != color;		
	}

	int Count()
	{
		int cnt = 0;
		for (int row = 0; row < SIZE; row++)
			for (int col = 0; col < SIZE; col++)
			{
				if (field[row][col] == our)
					cnt++;
			}
		return cnt;
	}

	Move nextMove(Figure color)
	{
		bool bot1119 = false;
		if (Count() < 8)
		{
			bot1119 = true;
		}

		int best = -1;
		Move bestMove;
		for (int row = 0; row < SIZE; ++row)
			for (int col = SIZE - 1; col >= 0; --col)
				if (field[row][col] == color)
				{
					int dr = color == WHITE ? 1 : -1;
					for (int dc = -1; dc <= 1; dc++)
					{
						Move mv(row, col, row + dr, col + dc);
						if (canMove(color, mv))
						{
							int cost = bot1119 ? Cost2(color,mv) : Cost(color, mv);
							if (cost > best)
							{
								best = cost;
								bestMove = mv;
							}
						}							
					}
				}
		if (best == -1)
			plog("Not find valid move: " + ('0' + color));
		cerr << "best = " << best << '\n';
		if (best == 0)
		{
			int dr,start,fin;
			if (color == WHITE)
			{
				start=0;
				fin=SIZE-1;
				dr=1;
			} else
			{
				start=SIZE-1;
				fin=0;
				dr=-1;
			}
			while (q[curr]!=-1)
			{
				for (int i=start; i!=fin; i+=dr)
				{
					if (field[i][q[curr]]==color && field[i+dr][q[curr]]==EMPTY)
					{						
						time++;
						int ccc = q[curr];
//						if (time%2==0) curr++;
						curr++;
						return move(Move(i,ccc,i+dr,ccc));
					}
				}
				curr++;
			}

			int best = -1;
			Move bestMove;
			for (int row = 0; row < SIZE; ++row)
				for (int col = SIZE - 1; col >= 0; --col)
					if (field[row][col] == color)
					{
						int dr = color == WHITE ? 1 : -1;
						for (int dc = -1; dc <= 1; dc++)
						{
							Move mv(row, col, row + dr, col + dc);
							if (canMove(color, mv))
							{
								int cost = Cost2(color, mv);
								if (cost > best)
								{
									best = cost;
									bestMove = mv;
								}
							}							
						}
					}
			return move(bestMove);
		}
		return move(bestMove);
	}

	int getType(Figure color, Move move)
	{
		if (field[move.to.row][move.to.col] == Enemy(color))
			return KILL;
		return FRONT;
	}

	bool canBeKilledByEnemy(Figure color, Ceil ceil)
	{
		int dr = color == WHITE ? -1 : 1;
		for (int dc = -1; dc <= 1; dc++)
		{
			Ceil enemy(ceil.row + dr, ceil.col + dc);
			if (enemy.valid() && field[enemy.row][enemy.col] == Enemy(color))
				return true;
		}
		return false;
	}
	
	int Cost(Figure color, Move move)
	{
		if (color == WHITE && move.to.row == SIZE - 1)
			return INF;
		if (color == BLACK && move.to.row == 0)
			return INF;
		Type type = getType(color,move);
		if (type == KILL) return 2 * abs(Finish[color] - move.to.row) - (int)canBeKilledByEnemy(color,move.to);
		return 0;
	}

	int Cost2(Figure color, Move move)
	{
		if (color == WHITE && move.to.row == SIZE - 1)
			return INF;
		if (color == BLACK && move.to.row == 0)
			return INF;
		Type type = getType(color,move);
		if (type == KILL) return 2 * abs(Finish[color] - move.to.row) - (int)canBeKilledByEnemy(color,move.to);
		return 2 * abs(Finish[Enemy(color)] - move.to.row) - (int)canBeKilledByEnemy(color,move.to);
	}

	int Enemy(Figure color)
	{
		return 3 - color;
	}
};

Move parseMove(string s)
{
	return Move(s[1] - '1', s[0] - 'a', s[3] - '1', s[2] - 'a');
}

int p[8] = {7, 6, 5, 4, 3, 2, 1, 0};

void init()
{
	int k=0;
	for (int g=0; g<100; g++)
	{
		q[k++]=p[0];
		for (int i=1; i<SIZE; i++)
		{
			q[k++]=p[i];
			for (int j=i-1; j>=0; j--)
			{
				q[k++]=p[j];
			}
		}
	}
	q[k] = -1;
	curr=0;
	time=0;
}

int main()
{
	freopen("err","w",stderr);
	string command;
	Game game;

	init();

	while (1)
	{
		cin >> command;
		if (command == "Name")
		{
			cout << "Catalan Bot 13:38\n";
			cout.flush();
			continue;
		}
		if (command == "Quit")
		{
			return 0;
		}
		if (command == "Start")
		{
			game.our = WHITE;
			cout << game.nextMove(game.our).toString() << endl;
			cout.flush();
			game.clearHistory();
			continue;
		}
		if (game.our == EMPTY)
			game.our = BLACK;
		Move move;
		move = parseMove(command);
		game.move(move);
		game.clearHistory();

		cout << game.nextMove(game.our).toString() << endl;
		cout.flush();
		game.clearHistory();
	}
	return 0;
}
