// Arup Guha
// 8/3/2026
// Solution to 1990 UCF HS Programming Contest Problem: Chess Adjournment

import java.util.*;

public class adjourn {
	
	// So we can call contains...
	final public static String BLACK_PIECES = "kpnbrq";
	final public static String WHITE_PIECES = "KPNBRQ";
	
	// For printing.
	final public static String[] LABELS = {"     King", "  Pawn(s)", "Knight(s)",
										   "Bishop(s)", "  Rook(s)", " Queen(s)"};
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);	
		while (stdin.hasNext()) {
		
			// Get input and split names.
			String line = stdin.nextLine();
			StringTokenizer tok = new StringTokenizer(line,",");
			String bPlayer = tok.nextToken();
			String wPlayer = tok.nextToken();
			wPlayer = wPlayer.substring(1);
			
			// Get board.
			char[][] board = new char[8][];
			for (int i=0; i<8; i++)
				board[i] = stdin.nextLine().trim().toCharArray();
				
			// Get who is moving.
			String toMove = "Black";
			String tmp = stdin.nextLine().trim();
			if (tmp.equals("W"))
				toMove = "White";
				
			// Start the drudgery.
			System.out.println("Black Player: "+bPlayer);
			System.out.println();
			output(board, false);
			System.out.println();
			System.out.println("   a  b  c  d  e  f  g  h");
			for (int i=0; i<8; i++) {
			
				// Row (left) header.
				System.out.print((8-i)+" ");
				
				// Go to each item on the board.
				for (int j=0; j<8; j++) {
				
					// I will type this a bunch.
					char c = board[i][j];
					char pChar = Character.toUpperCase(c);
					
					// I got it down to three cases.
					if (c >= 'a' && c <= 'z')
						System.out.print("B"+pChar+" ");
					else if (c >= 'A' && c <= 'Z') 
						System.out.print("W"+pChar+" ");
					else
						System.out.print(""+c+c+" ");
				}
				
				// Row (right) header.
				System.out.println((8-i));
			}
			System.out.println("   a  b  c  d  e  f  g  h");
			System.out.println();
			
			// Now, we get to do it again, woohoo!
			System.out.println("White Player: "+wPlayer);
			System.out.println();
			output(board, true);
			System.out.println();
			
			// Ta da!
			System.out.println(toMove+" to move.");
			System.out.println();
		}
	}
	
	// Output the piece structure for white (if isWhite is true) or black (if it's false).
	public static void output(char[][] board, boolean isWhite) {
		
		// Who I look for in my grid.
		String cmp = isWhite ? WHITE_PIECES : BLACK_PIECES;
		
		// The order we do this.
		for (int i=0; i<BLACK_PIECES.length(); i++) {
			
			// First the label.
			System.out.print(LABELS[i]+":");
			
			// Just go through the whole board.
			for (int y=0; y<8; y++) {
				for (int z=0; z<8; z++) {
					
					// This is the piece we're looking for.
					if (board[y][z] == cmp.charAt(i))
						System.out.print(" "+(char)('a'+z)+""+(8-y));
				}
			}
			
			// End of line.
			System.out.println();
		}
	}
}