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

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];
	int danger[][] = new int[BOARD_SIZE][BOARD_SIZE];
	int ourD[][] = new int[BOARD_SIZE][BOARD_SIZE];
	Cell currentColor;
	Random random;

	public class GameMove implements Comparable <GameMove> {
		int sLine, sCol, eLine, eCol;
		int fff;
		int fff2;
		boolean isCapture;
		
		GameMove(String move){
			sCol = (int)move.charAt(0) - 'a';
			sLine = (int)move.charAt(1) - '1';
			
			eCol = (int)move.charAt(2) - 'a';
			eLine = (int)move.charAt(3) - '1';
			
			isCapture = (board[eLine][eCol] != Cell.EMPTY);
			if (currentColor == Cell.WHITE) {
				fff = sLine;
			} else {
				fff = -sLine;
			}
			
			fff2 = (int)(Math.random() * 10000) % 17;
		}
		
		public String toString(){
			return  String.valueOf((char)(sCol+'a')) + String.valueOf(sLine+1) +
					String.valueOf((char)(eCol+'a')) + String.valueOf(eLine+1);
		}
		
		GameMove(int _sx, int _sy, int _ex, int _ey){
			sLine = _sx;
			sCol = _sy;
			eLine = _ex;
			eCol = _ey;
			isCapture = (board[eLine][eCol] != Cell.EMPTY);
			if (currentColor == Cell.WHITE) {
				fff = sLine;
			} else {
				fff = -sLine;
			}
			fff2 = (int)(Math.random() * 10000) % 17;
		}
		
		boolean isEatMove(){
			return isCapture;
		}
		
		boolean isWinMove(){
			return eLine == 0 || eLine == BOARD_SIZE - 1;
		}
		
		boolean isDangerMove(){
			return danger[eLine][eCol] - ourD[eLine][eCol] > 0;
		}
		
		boolean isFreeMove(){
			return danger[eLine][eCol] == 0;
		}
		
		public int compareTo(GameMove second) {
			if (this.fff == second.fff){
				return this.fff2 - second.fff2;
			}
			return -this.fff + second.fff;
		}
		
		int underAttack(){
			return danger[sLine][sCol]; 
		}
	}

	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 line=0; line<BOARD_SIZE; line++){
			for (int col=0; col<BOARD_SIZE; col++){
				if (line <= 1) {
					board[line][col] = Cell.WHITE;
				} else if (line >= BOARD_SIZE-2)  {
					board[line][col] = Cell.BLACK;
				} else {
					board[line][col] = Cell.EMPTY;
				}
			}
		}
		currentColor = Cell.WHITE;
		random = new Random(314159265358L);
	}

	private void makeMove(GameMove move){
		board[move.eLine][move.eCol] = board[move.sLine][move.sCol];
		board[move.sLine][move.sCol] = Cell.EMPTY;
		currentColor = Cell.opposite(currentColor);
	}

	private ArrayList<GameMove> genMoves(){
		ArrayList<GameMove> moves = new ArrayList<GameMove>();
		for (int line = 0; line < BOARD_SIZE; line++){
			for (int col = 0; col < BOARD_SIZE; col++){
				if (board[line][col] == currentColor){
					for (int dCol = -1; dCol <= 1; dCol++){
						int nLine = line + ((currentColor == Cell.WHITE) ? 1 : -1);
						int nCol = col + dCol;
						if (validForMove(nLine, nCol) && (dCol != 0 || board[nLine][nCol] == Cell.EMPTY)){
							moves.add(new GameMove(line,col,nLine,nCol));
						}
					}
				}
			}
		}
		return moves;
	}
	
	private GameMove getNextMove(){
		ArrayList <GameMove> moves = genMoves();
		Collections.sort(moves);
		
		// to win
		for (GameMove m: moves){
			if (m.isWinMove()) {
				makeMove(m);
				return m;
			}
		}
		
		
		// to back loose
		for (GameMove m: moves) {
			if ((m.sLine <= 1 && currentColor == Cell.WHITE ) || (m.sLine >= 6 && currentColor == Cell.BLACK)) {
				if (m.underAttack() > 0 && board[m.eLine][m.eCol] == Cell.opposite(currentColor)) {
					makeMove(m);
					return m;
				}
			}
		}
		
		// to pre win
		
		for (GameMove m: moves){
			if (m.sLine == 2 && currentColor == Cell.BLACK || m.sLine == 6 && currentColor == Cell.WHITE){
				if (m.isFreeMove()) {
					makeMove(m);
					return m;
				}
			}
		}
				
		for (GameMove m: moves){
			if (m.underAttack() > 0 && m.isFreeMove() && board[m.eLine][m.eCol] == Cell.opposite(currentColor)){
				makeMove(m);
				return m;
			}
		}
		
		for (GameMove m: moves){
			if (m.underAttack() > 0 && m.isFreeMove()){
				makeMove(m);
				return m;
			}
		}
		
		for (GameMove m: moves){
			if (m.underAttack() > 0 && board[m.eLine][m.eCol] == Cell.opposite(currentColor)) {
				makeMove(m);
				return m;
			}
		}
		
		
		for (GameMove m: moves){
			if (m.isEatMove() && !m.isDangerMove()) {
				makeMove(m);
				return m;
			}
		}
		
		for (GameMove m: moves){
			if (m.isFreeMove()) {
				makeMove(m);
				return m;
			}
		}
		
		for (GameMove m: moves) {
			if (danger[m.eLine][m.eCol] < ourD[m.eLine][m.eCol]) {
				makeMove(m);
				return m;
			}
		}
		makeMove(moves.get(0));		
		return moves.get(0);
	}
	
	
	boolean isField(int i, int j) {
		return 0 <= i && i < BOARD_SIZE && 0 <= j && j < BOARD_SIZE;
	}
	
	void computeDanger(){
		for (int []ar : danger){
			Arrays.fill(ar, 0);
		}
		for (int line = 0; line < BOARD_SIZE; line++) {
			for (int col = 0; col < BOARD_SIZE; col++){
				if (board[line][col] != currentColor && board[line][col] != Cell.EMPTY) {
					int di;
					if (board[line][col] == Cell.WHITE) {
						di = 1;
					} else {
						di = -1;
					}
					if (isField(line + di, col + 1)) {
						danger[line + di][col + 1]++;
					}
					if (isField(line + di, col - 1)) {
						danger[line + di][col - 1]++;
					}
				}
			}
		}
		
		for (int []ar : ourD){
			Arrays.fill(ar, 0);
		}
		
		for (int line = 0; line < BOARD_SIZE; line++) {
			for (int col = 0; col < BOARD_SIZE; col++){
				if (board[line][col] == currentColor) {
					int di;
					if (board[line][col] == Cell.WHITE) {
						di = 1;
					} else {
						di = -1;
					}
					if (isField(line + di, 1 + col)) {
						ourD[line + di][col + 1]++;
					}
					if (isField(line + di, col - 1)) {
						ourD[line + di][col - 1]++;
					}
				}
			}
		}
	}

	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("IOSIF KOBZON");
				out.flush();
			}
			else if (theirMove.equals("Quit")){
				return;
			}
			else{
				if (!theirMove.equals("Start")){
					makeMove(new GameMove(theirMove));					
					computeDanger();
				}
				out.println(getNextMove().toString());
				out.flush();
			}
		}
	}
}
