/*------------------------------------------------------------
TEAM17
A
234
Target: Java6; Platform: Win32; Comment: Java (JDK 6)
------------------------------------------------------------*/
// Alfa-beta bot 
// Ural Championship 2010 Game Tour
// Author: Boojum

import java.util.*;
import java.io.*;

import javax.swing.text.MaskFormatter;

public class RandomBot {
	public static void main(String[] argv) throws IOException {
		new RandomBot().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;
	Random random;

	final double WIN = 1000000000;
	final double distPow = 2.5;
	final double penForPiece = 5000;
	final double agro = 0.2;
	final int maxMov = 6;
	final int maxLev = 6;
	final double kilKoe = 1000000;
	final double koeEnd = 200000;

	public class GameMove implements Comparable<GameMove> {
		int sx, sy, ex, ey;
		boolean is_capture;
		double prior;

		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);
		}

		public int compareTo(GameMove o) {
			return Double.compare(prior, o.prior);
		}
	}

	private void makeMove(GameMove move) {
		board[move.ex][move.ey] = board[move.sx][move.sy];
		board[move.sx][move.sy] = Cell.EMPTY;
		currentColor = Cell.opposite(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);
	}

	class State {
		private static final double koeClearLine = 10000;
		public Cell board[][] = new Cell[BOARD_SIZE][BOARD_SIZE];
		public Cell currentColor;
		public int level;
		public GameMove chMove;

		private void makeMove(GameMove move, Cell currentColor) {
			board[move.ex][move.ey] = board[move.sx][move.sy];
			board[move.sx][move.sy] = Cell.EMPTY;
			// currentColor = Cell.opposite(currentColor);
		}

		public State(Cell[][] sboard, Cell curColor) {
			board = new Cell[BOARD_SIZE][];
			for (int i = 0; i < BOARD_SIZE; i++)
				board[i] = sboard[i].clone();
			currentColor = curColor;
			level = 0;
		}

		public State(State st) {
			board = new Cell[BOARD_SIZE][];
			for (int i = 0; i < BOARD_SIZE; i++)
				board[i] = st.board[i].clone();
			currentColor = Cell.opposite(st.currentColor);
			level = st.level + 1;
		}

		private int getDeltaY() {
			return ((currentColor == Cell.WHITE) ? 1 : -1);
		}

		private int getFinalY() {
			return ((currentColor == Cell.WHITE) ? 7 : 0);
		}

		private ArrayList<GameMove> genMoves() {
			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 + getDeltaY();
							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;
		}

		private ArrayList<GameMove> genPositions() {
			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) {
						moves.add(new GameMove(i, j, i, j));
					}
				}
			}
			return moves;
		}

		private ArrayList<GameMove> genOppPositions() {
			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] == Cell.opposite(currentColor)) {
						moves.add(new GameMove(i, j, i, j));
					}
				}
			}
			return moves;
		}

		/*
		 * private ArrayList<GameMove> genOppMoves() { 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] ==
		 * Cell.opposite(currentColor)) { for (int dj = -1; dj <= 1; dj++) { int
		 * ni = i - getDeltaY(); 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; }
		 */

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

		public boolean validForCheck(int x, int y) {
			return (x >= 0 && x < BOARD_SIZE && y >= 0 && y < BOARD_SIZE);
		}

		private boolean processWiningMoves(ArrayList<GameMove> moves) {
			for (GameMove gm : moves)
				if (gm.ex == getFinalY()) {
					moves.clear();
					moves.add(gm);
					return true;
				}
			return false;
		}

		private double distFunc(int d) {
			return (Math.pow(d, distPow));
		}

		public double calc() {
			ArrayList<GameMove> moves = genMoves();
			if (processWiningMoves(moves)) {
				chMove = moves.get(0);
				return WIN;
			}
			if (level >= maxLev) {
				ArrayList<GameMove> posit = genPositions();
				ArrayList<GameMove> oppPosit = genOppPositions();
				double sumDistPow = 0;
				for (GameMove gm : posit)
					sumDistPow += distFunc(Math.abs(getFinalY() - gm.ex));
				for (GameMove gm : oppPosit)
					sumDistPow += distFunc(Math.abs(8 - getFinalY() + gm.ex))
							/ agro;
				ArrayList<GameMove> captures = new ArrayList<GameMove>();
				Iterator<GameMove> iMoves = moves.iterator();
				while (iMoves.hasNext()) {
					GameMove gm = iMoves.next();
					if (gm.is_capture) {
						iMoves.remove();
						captures.add(gm);
					}
				}
				double sumDef = 0;
				for (GameMove gm : posit) {
					int co = 0;
					int ca = 0;
					for (int i = -1; i < 2; i += 1)
						if (validForCheck(gm.ex + getDeltaY(), gm.ey + i))
							if (board[gm.ex + getDeltaY()][gm.ey + i] == Cell
									.opposite(currentColor))
								co++;
					for (int i = -1; i < 2; i += 1)
						if (validForCheck(gm.ex - getDeltaY(), gm.ey + i))
							if (board[gm.ex - getDeltaY()][gm.ey + i] == currentColor)
								ca++;
					sumDef += (ca / agro - co) * penForPiece;
				}
				return sumDef + sumDistPow + (posit.size()-oppPosit.size())*kilKoe;
			} else {
				GameMove[] mas = new GameMove[0];
				mas = moves.toArray(mas);
				for (int i = 0; i < mas.length; i++) {
					double delta1 = 0.0;
					delta1 -= distFunc(Math.abs(getFinalY() - mas[i].sx));
					delta1 += distFunc(Math.abs(getFinalY() - mas[i].ex));
					int co = 0;
					int ca = 0;
					for (int j = -1; j < 2; j += 1)
						if (validForCheck(mas[i].ex + getDeltaY(), mas[i].ey
								+ j))
							if (board[mas[i].ex + getDeltaY()][mas[i].ey + j] == Cell
									.opposite(currentColor))
								co++;
					for (int j = -1; j < 2; j += 1)
						if (validForCheck(mas[i].ex - getDeltaY(), mas[i].ey
								+ j))
							if (board[mas[i].ex - getDeltaY()][mas[i].ey + j] == currentColor)
								ca++;
					
					int[] sms = new int[BOARD_SIZE];
					for (int k=0;k<BOARD_SIZE;k++)
						for (int j=0;j<BOARD_SIZE;j++)
							if (board[k][j]==currentColor)
								sms[j]++;
					sms[mas[i].sy]--;
					sms[mas[i].ey]++;
					/*int[] sms1 = new int[BOARD_SIZE];
					int[] sms2 = new int[BOARD_SIZE];
					for (int k=0;k<BOARD_SIZE;k++)
						for (int j=0;j<BOARD_SIZE;j++)
							for (int kk=0;kk<BOARD_SIZE;kk++) {
							if (board[k][j]==currentColor&&(k-getFinalY())==(k-j))
								sms1[j]++;
							if (board[k][j]==currentColor&&(k-getFinalY())==(j-k))
								sms2[j]++;
							}*/
					for (int j=0;j<BOARD_SIZE;j++)
						if (sms[j]==0)
							delta1-=koeClearLine;
					/*for (int j=0;j<BOARD_SIZE;j++)
						if (sms1[j]==0)
							delta1-=koeClearLine;
					for (int j=0;j<BOARD_SIZE;j++)
						if (sms2[j]==0)
							delta1-=koeClearLine;*/
					delta1 += (ca / agro - co) * penForPiece;
					if (board[mas[i].ex][mas[i].ey]==Cell.opposite(currentColor))
						delta1+=kilKoe;
					if (Math.abs(getFinalY() - mas[i].ex)<4) delta1+=koeEnd;
					mas[i].prior = -delta1;
				}
				Arrays.sort(mas);
				int c = 0;
				GameMove bestMove = null;
				double bestCo = 2 * WIN;
				for (GameMove gm : mas) {
					c++;
					if (c > maxMov)
						break;
					State ns = new State(this);
					ns.makeMove(gm, currentColor);
					double coe = ns.calc();
					if (coe < bestCo) {
						bestMove = gm;
						bestCo = coe;
					}
				}
				chMove = bestMove;
				return -bestCo;
			}
		}
	}

	private GameMove getNextMove() {
		/*
		 * ArrayList<GameMove> moves = genMoves(); processWiningMoves(moves); if
		 * (moves.size() == 1) return moves.get(0); ArrayList<GameMove> captures
		 * = new ArrayList<GameMove>(); Iterator<GameMove> iMoves =
		 * moves.iterator(); while (iMoves.hasNext()) { GameMove gm =
		 * iMoves.next(); if (gm.is_capture) { iMoves.remove();
		 * captures.add(gm); } } GameMove move = null; if (captures.isEmpty()) {
		 * ArrayList<GameMove> uf = separateUnderFire(moves); if
		 * (moves.isEmpty()) move = uf.get(genR.nextInt(uf.size())); else move =
		 * moves.get(genR.nextInt(moves.size())); } else move =
		 * captures.get(genR.nextInt(captures.size())); makeMove(move); return
		 * move;
		 */
		State cs = new State(board, currentColor);
		cs.calc();
		makeMove(cs.chMove);
		return cs.chMove;
	}

	public void run() throws IOException {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);

		initBoard();
		while (true) {
			String theirMove = in.nextLine();
			if (theirMove.equals("Name")) {
				out.println("Busy Beaver");
				out.flush();
			} else if (theirMove.equals("Quit")) {
				return;
			} else {
				if (!theirMove.equals("Start")) {
					makeMove(new GameMove(theirMove));
				}
				out.println(getNextMove().toString());
				out.flush();
			}
		}
	}
}
