/*------------------------------------------------------------
TEAM04
A
210
Target: Java6; Platform: Win32; Comment: Java (JDK 6)
------------------------------------------------------------*/
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] argv) throws IOException {
		new Main().run();
	}

	Scanner in;
	PrintWriter out;

	public static final int BOARD_SIZE = 8;

	public static enum Cell {
		EMPTY, WHITE, BLACK;
		public static Cell opposite(Cell cell) {
			return (cell == WHITE) ? BLACK : WHITE;
		}
	}

	Cell board[][] = new Cell[BOARD_SIZE][BOARD_SIZE];
	Cell currentColor;
	Cell ourColor;
	Random random;
	GameState state;

	public class GameMove {
		int sx, sy, ex, ey;
		boolean is_capture;

		GameMove(String move) {
			sx = (int) move.charAt(1) - '1';
			sy = (int) move.charAt(0) - 'a';
			ex = (int) move.charAt(3) - '1';
			ey = (int) move.charAt(2) - 'a';
			is_capture = (board[ex][ey] != Cell.EMPTY);
		}

		public String toString() {
			return String.valueOf((char) (sy + 'a')) + String.valueOf(sx + 1)
					+ String.valueOf((char) (ey + 'a'))
					+ String.valueOf(ex + 1);
		}

		GameMove(int _sx, int _sy, int _ex, int _ey) {
			sx = _sx;
			sy = _sy;
			ex = _ex;
			ey = _ey;
			is_capture = (board[ex][ey] != Cell.EMPTY);
		}
	}

	static class Pair<T, V> {
		T first;
		V second;

		public Pair(T first, V second) {
			super();
			this.first = first;
			this.second = second;
		}
	}

	static class CellPos {
		Cell cell;
		int x, y;

		public CellPos(Cell cell, int x, int y) {
			super();
			this.cell = cell;
			this.x = x;
			this.y = y;
		}

	}

	public class GameState {
		Cell board[][];

		public GameState(Cell[][] board) {
			super();
			this.board = board;
			for (int i = 0; i < BOARD_SIZE; ++i)
				for (int j = 0; j < BOARD_SIZE; ++j) {
					if (board[i][j] != Cell.EMPTY) {
						add(board[i][j], i, j);
					}
				}
		}

		Set<CellPos> set = new HashSet<CellPos>();

		void add(Cell cell, int x, int y) {
			// set.add(new CellPos(cell, x, y));
		}

		void remove(Cell cell, int x, int y) {
			// set.remove(new CellPos(cell, x, y));
		}

		double calcFunc() {
			int ourCnt = 0;
			int theirCnt = 0;
			// List<Pair<Integer, Boolean>> ourY = new ArrayList<Pair<Integer,
			// Boolean>>();
			// List<Pair<Integer, Boolean>> theirY = new ArrayList<Pair<Integer,
			// Boolean>>();

			double ret = 0.0;

			for (int i = 0; i < BOARD_SIZE; ++i) {
				for (int j = 0; j < BOARD_SIZE; ++j) {
					if (board[i][j] == ourColor) {
						++ourCnt;
						int yy;
						boolean rr = checkRub(i, j);
						if (ourColor == Cell.WHITE) {
							yy = BOARD_SIZE - i - 1;
						} else {
							yy = i;
						}

						double kk = 1.0;
						if (rr)
							kk = 0.3;
						double f = 1e30;
						if (yy != 0) {
							yy = 7 - yy;
							f = yy * yy;
						}
						ret += kk * f;

					} else if (board[i][j] != Cell.EMPTY) {
						++theirCnt;
						int yy;
						boolean rr = checkRub(i, j);
						if (ourColor == Cell.BLACK) {
							yy = BOARD_SIZE - i - 1;
						} else {
							yy = i;
						}

						double kk = 2.0;
						if (rr)
							kk = 0.4;
						double f = 1e30;
						if (yy != 0) {
							yy = 7 - yy;
							f = yy * yy;
						}
						ret -= kk * f;

					}
				}
			}

			if (ourColor != currentColor)
				return -ret;

			return ret;
		}

		double calcFunc2() {
			int ourCnt = 0;
			int theirCnt = 0;
			List<Pair<Integer, Boolean>> ourY = new ArrayList<Pair<Integer, Boolean>>();
			List<Pair<Integer, Boolean>> theirY = new ArrayList<Pair<Integer, Boolean>>();

			for (int i = 0; i < BOARD_SIZE; ++i) {
				for (int j = 0; j < BOARD_SIZE; ++j) {
					if (board[i][j] == ourColor) {
						++ourCnt;
						if (ourColor == Cell.WHITE) {
							ourY.add(new Pair<Integer, Boolean>(BOARD_SIZE - i
									- 1, checkRub(i, j)));
						} else {
							ourY.add(new Pair<Integer, Boolean>(i, checkRub(i,
									j)));
						}

					} else if (board[i][j] != Cell.EMPTY) {
						++theirCnt;
						if (ourColor == Cell.BLACK) {
							theirY.add(new Pair<Integer, Boolean>(BOARD_SIZE
									- i - 1, checkRub(i, j)));
						} else {
							theirY.add(new Pair<Integer, Boolean>(i, checkRub(
									i, j)));
						}
					}
				}
			}

			double ret = 0.0;
			for (Pair<Integer, Boolean> x : ourY) {
				double kk = 1.0;
				if (x.second)
					kk = 0.1;

				double f = 1e30;
				if (x.first != 0)
					f = (7 - x.first) * (7 - x.first);

				ret += kk * f;
			}

			for (Pair<Integer, Boolean> x : ourY) {
				double kk = 2.0;
				if (x.second)
					kk = 0.2;

				double f = 1e30;
				if (x.first != 0)
					f = (7 - x.first) * (7 - x.first);

				ret -= kk * f;
			}

			return ret;
		}

		boolean checkRub(int i, int j) {
			int nap = 1;
			if (board[i][j] == Cell.BLACK) {
				nap = -1;
			}

			if (validForMove(i + nap, j + 1, board[i][j])) {
				if (board[i + nap][j + 1] != Cell.EMPTY) {
					return true;
				}
			}

			if (validForMove(i + nap, j - 1, board[i][j])) {
				if (board[i + nap][j - 1] != Cell.EMPTY) {
					return true;
				}
			}

			return false;
		}
	}

	public boolean validForMove(int x, int y, Cell color) {
		return (x >= 0 && x < BOARD_SIZE && y >= 0 && y < BOARD_SIZE && board[x][y] != color);
	}

	public boolean validForMove(int x, int y) {
		return (x >= 0 && x < BOARD_SIZE && y >= 0 && y < BOARD_SIZE && board[x][y] != currentColor);
	}

	private void initBoard() {
		board = new Cell[BOARD_SIZE][BOARD_SIZE];
		for (int i = 0; i < BOARD_SIZE; i++) {
			for (int j = 0; j < BOARD_SIZE; j++) {
				if (i <= 1)
					board[i][j] = Cell.WHITE;
				else if (i >= BOARD_SIZE - 2)
					board[i][j] = Cell.BLACK;
				else
					board[i][j] = Cell.EMPTY;
			}
		}
		currentColor = Cell.WHITE;
		random = new Random(314159265358L);
	}

	private void makeMove(GameState state, GameMove move) {
		state.remove(state.board[move.ex][move.ey], move.ex, move.ey);
		state.remove(state.board[move.sx][move.sy], move.sx, move.sy);
		state.board[move.ex][move.ey] = state.board[move.sx][move.sy];
		state.board[move.sx][move.sy] = Cell.EMPTY;

		state.add(state.board[move.ex][move.ey], move.ex, move.ey);
		currentColor = Cell.opposite(currentColor);
	}

	private void unMove(GameMove move, Cell firstCell) {
		makeMove(state, new GameMove(move.ex, move.ey, move.sx, move.sy));
		board[move.ex][move.ey] = firstCell;
		if (firstCell != Cell.EMPTY) {
			state.add(firstCell, move.ex, move.ey);
		}
	}

	private ArrayList<GameMove> genMoves(Cell board[][]) {
		ArrayList<GameMove> moves = new ArrayList<GameMove>();
		for (int i = 0; i < BOARD_SIZE; i++) {
			for (int j = 0; j < BOARD_SIZE; j++) {
				if (board[i][j] == currentColor) {
					for (int dj = -1; dj <= 1; dj++) {
						int ni = i + ((currentColor == Cell.WHITE) ? 1 : -1);
						int nj = j + dj;
						if (validForMove(ni, nj)
								&& (dj != 0 || board[ni][nj] == Cell.EMPTY)) {
							moves.add(new GameMove(i, j, ni, nj));
						}
					}
				}
			}
		}
		return moves;
	}

	int TEST;
	boolean ended = false;

	int MAX_DEPT = 4;

	long time = 0;

	double brute(GameState state, int dep) {
		if (TEST == 10000) {
			TEST = 0;
			if (new Date().getTime() - time >= 2000L)
				ended = true;
		}
		// ++TEST;
		if (ended) {
			return -1e30;
		}
		if (dep == MAX_DEPT) {
			return state.calcFunc();
		} else {
			double ret = -1e31;
			for (int i = 0; i < BOARD_SIZE; i++) {
				for (int j = 0; j < BOARD_SIZE; j++) {
					if (board[i][j] == currentColor) {
						for (int dj = -1; dj <= 1; dj++) {
							int ni = i
									+ ((currentColor == Cell.WHITE) ? 1 : -1);
							int nj = j + dj;
							if (validForMove(ni, nj)
									&& (dj != 0 || board[ni][nj] == Cell.EMPTY)) {
								GameMove move = new GameMove(i, j, ni, nj);
								Cell cell = board[move.ex][move.ey];
								makeMove(state, move);
								ret = Math.max(-brute(state, dep + 1), ret);
								unMove(move, cell);
							}
						}
					}
				}
			}

			return ret;
		}
	}

	private GameMove getNextMove() {
		TEST = 0;
		int cnt = 0;
		for (int i = 0; i < 8; ++i)
			for (int j = 0; j < 8; ++j)
				if (board[i][j] == currentColor) {
					++cnt;
				}
		// if (cnt <= 10) {
		// MAX_DEPT = 6;
		// }
		// if (cnt <= 5) {
		// MAX_DEPT = 8;
		// }
		// if (cnt <= 2) {
		// MAX_DEPT = 10;
		// }
		ourColor = currentColor;
		ArrayList<GameMove> moves = genMoves(board);
		GameMove bestMove = null;
		double bestFunc = -1e+31;
		GameState state = new GameState(board);
		int NN = 1;
		int nap = 0;
		if (currentColor == Cell.WHITE) {
			nap = 7;
		}
		for (GameMove move : moves) {
			if (move.ex == nap) {
				makeMove(state, move);
				return move;
			}
			Cell cell = board[move.ex][move.ey];
			makeMove(state, move);
			ended = false;
			double val = -brute(state, 1);
			unMove(move, cell);

			if (val > bestFunc) {
				bestFunc = val;
				bestMove = move;
				NN = 1;
			} else if (Math.abs(val - bestFunc) < 0.01) {
				NN++;
				double test = 1.0 / NN;
				if (test > Math.random()) {
					bestFunc = val;
					bestMove = move;
				}
			}
		}
		// out.println(TEST);
		makeMove(state, bestMove);
		return bestMove;
	}

	public void run() throws IOException {
		in = new Scanner(System.in);
		// in = new Scanner(new File("input.txt"));
		out = new PrintWriter(System.out);

		initBoard();
		state = new GameState(board);
		while (true) {
			String theirMove = in.nextLine();
			if (theirMove.equals("Name")) {
				out.println("Op op");
				out.flush();
			} else if (theirMove.equals("Quit")) {
				return;
			} else {
				if (!theirMove.equals("Start")) {
					makeMove(state, new GameMove(theirMove));
				}
				out.println(getNextMove().toString());
				out.flush();
			}
		}
	}
}
