// Random bot for "Breakthrough" game
// Ural Championship 2010 Game Tour
// Author: Alexey Samsonov

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];
	Cell currentColor;
	Random random;

	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.format("%1$%2$%3$%4$", sy+'a', sx+1, ey+'a', ex+1);
			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 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(GameMove move){
		board[move.ex][move.ey] = board[move.sx][move.sy];
		board[move.sx][move.sy] = Cell.EMPTY;
		currentColor = Cell.opposite(currentColor);
	}

	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 + ((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;
	}

	private GameMove getNextMove(){
		ArrayList<GameMove> moves = genMoves();
		GameMove move = moves.get(random.nextInt(moves.size()));
		makeMove(move);
		return move;
	}

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