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

public class chess_sp implements Runnable {

	public static void main(String[] args) {
		new Thread(new chess_sp()).start();
	}

	public void run() {
		try {
			Locale.setDefault(Locale.US);
			br = new BufferedReader(new FileReader(FILENAME + ".in"));
			out = new PrintWriter(FILENAME + ".out");
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	BufferedReader br;

	PrintWriter out;

	StringTokenizer st;

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(br.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	void myAssert(boolean e, String s) {
		if (!e) {
			throw new Error("Assertion failure " + s);
		}
	}

	private static final String FILENAME = "chess";
	
	void assertPos(String pos) {
		assert pos.length() == 2;
		assert pos.charAt(0) >= 'a' && pos.charAt(0) <= 'h';
		assert pos.charAt(1) >= '1' && pos.charAt(1) <= '8';
	}

	public void solve() throws IOException {
		Figure[] figs = new Figure[]{new WhitePawn(), new BlackPawn(), new Knight(), new Bishop(), new Rook(), new Queen(), new King()};
		int n = nextInt();
		assert 0 <= n && n <= 1000;
		String pos = nextToken();
		assertPos(pos);
		for (Figure f : figs) {
			f.setPosition(pos);
		}
		for (int i = 0; i < n; i++) {
			pos = nextToken();
			assertPos(pos);
			for (Figure f : figs) {
				f.move(pos);
			}
		}
		for (Figure f : figs) {
			if (f.valid) {
				out.println(f);
			}
		}
	}
	
	abstract class Figure {
		int x, y;
		boolean valid = true;
		String name;
		
		void setPosition(String s) {
			x = s.charAt(0) - 'a';
			y = s.charAt(1) - '1';
		}
		
		void move(String s) {
			int nx = s.charAt(0) - 'a';
			int ny = s.charAt(1) - '1';
			assert x != nx || y != ny;
			checkMove(nx, ny);
			x = nx;
			y = ny;
		}

		abstract protected void checkMove(int nx, int ny);
		
		@Override
		public String toString() {
			return name;
		}
	}
	
	class WhitePawn extends Figure {

		WhitePawn() {
			name = "white pawn";
		}
		
		@Override
		void setPosition(String s) {
			x = s.charAt(0) - 'a';
			y = s.charAt(1) - '1';
			if (y == 0) {
				valid = false;
			}
		}
		
		protected void checkMove(int nx, int ny) {
			if (nx != x) valid = false;
			if (!(ny == y + 1 || (ny == y + 2 && y == 1))) valid = false;
		}
	}
	
	class BlackPawn extends Figure {

		BlackPawn() {
			name = "black pawn";
			if (y == 7) {
				valid = false;
			}
		}
		
		@Override
		void setPosition(String s) {
			x = s.charAt(0) - 'a';
			y = s.charAt(1) - '1';
			if (y == 7) {
				valid = false;
			}
		}
		
		protected void checkMove(int nx, int ny) {
			if (nx != x) valid = false;
			if (!(ny == y - 1 || (ny == y - 2 && y == 6))) valid = false;
		}
	}
	
	class Knight extends Figure {

		Knight() {
			name = "knight";
		}
		
		protected void checkMove(int nx, int ny) {
			int dx = Math.abs(nx - x);
			int dy = Math.abs(ny - y);
			if (!((dx == 2 && dy == 1) || (dx == 1 && dy == 2))) valid = false;
		}
	}
	
	class Bishop extends Figure {

		Bishop() {
			name = "bishop";
		}
		
		protected void checkMove(int nx, int ny) {
			int dx = Math.abs(nx - x);
			int dy = Math.abs(ny - y);
			if (dx != dy) valid = false;
		}
	}
	
	class Rook extends Figure {

		Rook() {
			name = "rook";
		}
		
		protected void checkMove(int nx, int ny) {
			int dx = Math.abs(nx - x);
			int dy = Math.abs(ny - y);
			if (dx != 0 && dy != 0) valid = false;
		}
	}
	
	class Queen extends Figure {

		Queen() {
			name = "queen";
		}
		
		protected void checkMove(int nx, int ny) {
			int dx = Math.abs(nx - x);
			int dy = Math.abs(ny - y);
			if (dx != 0 && dy != 0 && dx != dy) valid = false;
		}
	}
	
	class King extends Figure {

		King() {
			name = "king";
		}
		
		protected void checkMove(int nx, int ny) {
			int dx = Math.abs(nx - x);
			int dy = Math.abs(ny - y);
			if (dx > 1 || dy > 1) valid = false;
			if (dx != 0 && dy != 0 && dx != dy) valid = false;
		}
	}
}
