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

public class SampleBot {
	BufferedReader in;
	PrintWriter out;
	
	static public void main(String[] args) throws IOException {
		new SampleBot().run();
	}
	
	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(new OutputStreamWriter(System.out));
		
		initalize();
		Move move;
		while(true) {
			char[] query = in.readLine().toCharArray();
			switch(query[0]) {
			case 'S' : // start game
				ourColor = Color.WHITE;
				move = getMove();
				out.println(move.toString());
				out.flush();
				break;
			case 'N' : // output Name
				out.println("PermSU2");
				out.flush();
				break;
			case 'Q' : return;
			default : // make our move
				int sCol, sRow, eCol, eRow;
				sCol = query[0] - 'a';
				sRow = query[1] - '1';
				eCol = query[2] - 'a';
				eRow = query[3] - '1';
				makeMove(new Move(sCol, sRow, eCol, eRow, false, map[sRow][sCol].color));
				move = getMove();
				out.println(move.toString());
				out.flush();
			}
		}
	}
	
	void initalize() {
		map = new Cell[8][8];
		for(int i = 0; i < 8; i++) {
			map[0][i] = new Cell(0, i, Color.WHITE);
			map[1][i] = new Cell(1, i, Color.WHITE);
			map[6][i] = new Cell(6, i, Color.BLACK);
			map[7][i] = new Cell(7, i, Color.BLACK);
		}
		for(int j = 2; j < 5; j++) {
			for(int i = 0; i < 8; i++)
				map[j][i] = new Cell(j, i, Color.EMPTY);
		}
		ourColor = Color.BLACK;
		Random rnd = new Random();
		flang = (rnd.nextInt(12342435) % 2 == 0) ? Position.LEFT : Position.RIGHT;
		moveNum = 0;
	}
	
	// Main vars
	Cell[][] map;
	Color ourColor;
	Position flang;
	int moveNum;
	
	enum Position {LEFT, CENTER, RIGHT};
	
	////////////////////////////////////////////////////////////////////
	
	Move getMove() {
		if(moveNum < 5) {
			moveNum++;
			if(ourColor == Color.WHITE && flang == Position.LEFT)
			switch(moveNum - 1) {
			case 0 : return new Move(0, 1, 0, 2, false, ourColor);
			case 1 : return new Move(1, 1, 1, 2, false, ourColor);
			case 2 : return new Move(2, 1, 2, 2, false, ourColor);
			case 3 : return new Move(3, 1, 2, 2, false, ourColor);
			case 4 : return new Move(1, 0, 1, 1, false, ourColor);
			}
			else if(ourColor == Color.BLACK && flang == Position.LEFT)
			switch(moveNum - 1) {
				case 0 : return new Move(0, 6, 0, 5, false, ourColor);
				case 1 : return new Move(1, 6, 1, 5, false, ourColor);
				case 2 : return new Move(2, 6, 2, 5, false, ourColor);
				case 3 : return new Move(3, 6, 2, 5, false, ourColor);
				case 4 : return new Move(1, 7, 1, 6, false, ourColor);
			}
			else if(ourColor == Color.WHITE && flang == Position.RIGHT)
				switch(moveNum - 1) {
				case 0 : return new Move(5, 1, 5, 2, false, ourColor);
				case 1 : return new Move(6, 1, 6, 2, false, ourColor);
				case 2 : return new Move(7, 1, 7, 2, false, ourColor);
				case 3 : return new Move(4, 1, 5, 2, false, ourColor);
				case 4 : return new Move(6, 0, 6, 1, false, ourColor);
				}
				else if(ourColor == Color.BLACK && flang == Position.RIGHT)
				switch(moveNum - 1) {
					case 0 : return new Move(5, 6, 5, 5, false, ourColor);
					case 1 : return new Move(6, 6, 6, 5, false, ourColor);
					case 2 : return new Move(7, 6, 7, 5, false, ourColor);
					case 3 : return new Move(4, 6, 5, 5, false, ourColor);
					case 4 : return new Move(6, 7, 6, 6, false, ourColor);
				}
		}
		ArrayList<Cell> center = getCellsbyColor(ourColor, Position.CENTER);
		ArrayList<Cell> aflang = getCellsbyColor(ourColor, flang == Position.LEFT ? Position.RIGHT : Position.LEFT);
		Cell centerCell = getCellUnderAttack(center);
		Cell aflangCell = getCellUnderAttack(aflang);
		if(centerCell == null && aflangCell == null) {
			Path minPath = null;
			ArrayList<Cell> ourCells = getCellsbyColor(ourColor, flang);
			for(Cell c : ourCells) {
				Path path = getPath(c);
				if(path.length < minPath.length) {
					minPath = path; 
				}
			}
			if(minPath != null) {
				return getMoveFromPath(minPath);
			}
			else {
				ArrayList<Move> attackMoves = new ArrayList<Move>();
				ArrayList<Move> moveMoves = new ArrayList<Move>();
				ArrayList<Cell> cells = getCellsbyColor(ourColor, flang);
				for(Cell cell : cells) {
					ArrayList<Cell> forMove = cell.getNeighbours4Move();
					for(Cell acell : forMove) {
						if(acell.color != Color.EMPTY) {
							attackMoves.add(new Move(cell, acell));
						}
						else {
							if(acell.pos == flang)
								moveMoves.add(new Move(cell, acell));
						}
					}
				}
				if(attackMoves.size() != 0) {
					Random rnd = new Random();
					return attackMoves.get(Math.abs(rnd.nextInt(attackMoves.size())) % attackMoves.size());
				}
				else if(moveMoves.size() != 0) {
					Random rnd = new Random();
					return moveMoves.get(Math.abs(rnd.nextInt(moveMoves.size())) % moveMoves.size());
				}
				return null;
			}
		}
		else if(centerCell != null) {
			ArrayList<Cell> moves = centerCell.getNeighbours4Move();
			for(Cell cell : moves) {
				if(cell.color != ourColor) {
					return new Move(centerCell, cell);
				}
			}
		}
		else if(aflangCell != null) {
			ArrayList<Cell> moves = aflangCell.getNeighbours4Move();
			for(Cell cell : moves) {
				if(cell.color != ourColor) {
					return new Move(aflangCell, cell);
				}
			}
		}
		return null;
	}
	
	////////////////////////////////////////////////////////////////////
	
	Move getMoveFromPath(Path path) {
		return new Move(path.cells.get(0), path.cells.get(1));
	}
	
	////////////////////////////////////////////////////////////////////
	
	class Path {
		ArrayList<Cell> cells;
		int length;
		
		public Path() {
			cells = new ArrayList<Cell>();
			length = 0;
		}
		
		public void addCell(Cell cell) {
			cells.add(cell);
			length++;
		}
	}
	
	////////////////////////////////////////////////////////////////////
	
	public Path getPath(Cell cell) {
		Path ret = new Path();
		if(ourColor == Color.BLACK && cell.row >= 4) return null;
		if(ourColor == Color.WHITE && cell.row <= 3) return null;
		ArrayList<Cell> neighbours = cell.getNeighbours4Move();
		for(Cell acell : neighbours) {
			if(!underAttack(acell) && acell.color == Color.EMPTY) {
				ret.addCell(cell);
				ret.addCell(acell);
				return ret;
			}
		}
		return null;
	}
	
	////////////////////////////////////////////////////////////////////
	
	Cell getCellUnderAttack(ArrayList<Cell> list) {
		for(Cell cell : list) {
			if(underAttack(cell)) return cell;
		}
		return null; 
	}
	
	////////////////////////////////////////////////////////////////////
	
	boolean underAttack(Cell cell) {
		ArrayList<Cell> neighbours = cell.getNeighbours();
		for(Cell c : neighbours) {
			ArrayList<Cell> attack = c.getNeighbours4Move();
			if(attack.contains(cell)) return true;
		}
		return false;
	}
	
	////////////////////////////////////////////////////////////////////
	
	class Move {
		int startCol, startRow, endRow, endCol;
		boolean attack;
		Color color;
		
		public Move() {
			startCol = 0; startRow = 0;
			endRow = 0; endCol = 0;
			attack = false;
			color = Color.EMPTY;
		}
		
		public Move(Move move) {
			startCol = move.startCol;
			startRow = move.startRow;
			endCol = move.endCol;
			endRow = move.endRow;
			attack = move.attack;
			color = move.color;
		}
		
		public Move(int startCol, int startRow, int endCol, int endRow, boolean attack, Color color) {
			this.attack = attack;
			this.startCol = startCol;
			this.startRow = startRow;
			this.color = color;
			this.endCol = endCol;
			this.endRow = endRow;
		}
		
		public Move(Cell start, Cell end) {
			boolean attack = end.color != Color.EMPTY;
			int startCol = start.column, startRow = start.row, endCol = end.column, endRow = end.row;
			Color color = start.color;
			this.attack = attack;
			this.startCol = startCol;
			this.startRow = startRow;
			this.color = color;
			this.endCol = endCol;
			this.endRow = endRow;
		}
		
		public String toString() {
			return Character.toString((char)('a' + startCol)) + Integer.toString(startRow + 1) + Character.toString((char)('a' + endCol)) + Integer.toString(endRow + 1);
		}
	}
	
	/////////////////////////////////////////////////////////////
	
	void makeMove(Move move) {
		map[move.startRow][move.startCol].color = Color.EMPTY;
		map[move.endRow][move.endCol].color = move.color;
		
	}
	
	/////////////////////////////////////////////////////////////
	
	enum Color {WHITE, BLACK, EMPTY};
		
	ArrayList<Cell> getCellsbyColor(Color color, Position pos) {
		ArrayList<Cell> ret = new ArrayList<Cell>();
		for(int i = 0; i < 8; i++)
			for(int j = 0; j < 8; j++)
				if(map[i][j].color == color && map[i][j].pos == pos)
					ret.add(map[i][j]);
		return ret;
	}
	
	class Cell {
		int column, row;
		Color color;
		Position pos;
		
		public Cell() {
			column = row = 0;
			color = Color.EMPTY;
			pos = Position.CENTER;
		}
		
		public Cell(Cell c) {
			column = c.column;
			row = c.row;
			color = c.color;
			if(column < 3) pos = Position.LEFT;
			else if(column < 5) pos = Position.CENTER;
			else pos = Position.RIGHT;
		}
		
		public Cell(int row, int column, Color color) {
			this.color = color;
			this.column = column;
			this.row = row;
		}
		
		public ArrayList<Cell> getNeighbours() {
			int[][] d = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {-1, -1}, {-1, 1}, {1, 1}, {1, -1}};
			ArrayList<Cell> ret = new ArrayList<Cell>();
			for(int i = 0; i < 8; i++) {
				int curCol = column + d[i][0];
				int curRow = row + d[i][1];
				if(curCol >= 0 && curCol < 8 && curRow >= 0 && curRow < 8) {
					ret.add(map[curRow][curCol]);
				}
			}
			return ret;
		}
		
		public ArrayList<Cell> getNeighbours4Move() {
			if(color == Color.EMPTY) return null;
			int[][] d = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {-1, -1}, {-1, 1}, {1, 1}, {1, -1}};
			ArrayList<Cell> ret = new ArrayList<Cell>();
			for(int i = 0; i < 8; i++) {
				int curCol = column + d[i][0];
				int curRow = row + d[i][1];
				if(curCol >= 0 && curCol < 8 && curRow >= 0 && curRow < 8) {
					if(map[curRow][curCol].color == Color.EMPTY) {
						if(map[row][column].color == Color.BLACK) {
							if(d[i][1] < 0) ret.add(map[curRow][curCol]);
						}
						else {
							if(d[i][1] > 0) ret.add(map[curRow][curCol]);
						}
					}
					else if(map[curRow][curCol].color != map[row][column].color) {
						if(map[row][column].color == Color.BLACK) {
							if(d[i][1] < 0 && d[i][0] != 0) ret.add(map[curRow][curCol]);
						}
						else {
							if(d[i][1] > 0 && d[i][0] != 0) ret.add(map[curRow][curCol]);
						}
					}
				}
			}
			return ret;
		}
	}
}
