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

public class chess_ab implements Runnable {

	final int MAXN = 1000;
	
	private void solve() throws IOException {
		int n = in.nextInt();
		assert 0 <= n && n <= MAXN;
		int[] x = new int[n + 1];
		int[] y = new int[n + 1];
		for (int i = 0; i < n + 1; ++i) {
			String s = in.readLine();
			assert s.length() == 2;
			assert 'a' <= s.charAt(0) && s.charAt(0) <= 'h';
			x[i] = s.charAt(0) - 'a';
			assert '1' <= s.charAt(1) && s.charAt(1) <= '8';
			y[i] = s.charAt(1) - '1';
			if (i > 0) {
				assert x[i - 1] != x[i] || y[i - 1] != y[i];
			}
		}
		
		CheckMove[] mv = new CheckMove[]{new WhitePawn(), new BlackPawn(), new Knight(), new Bishop(), new Rook(), new Queen(), new King()};
		
		
		int cnt = 0;
		for (CheckMove m : mv) {
			boolean good = true; 
			for (int i = 0; i < n; ++i) {
				good &= m.canGo(x[i], y[i], x[i + 1], y[i + 1]);
			}
			for (int i = 0; i < n + 1; ++i) {
				good &= m.canBe(x[i], y[i]);
			}
			if (good) { 
				out.println(m.getName());
				++cnt;
			}
		}
		assert cnt > 0;
		
	}
	
	interface CheckMove {	
		boolean canGo(int x1, int y1, int x2, int y2);
		boolean canBe(int x, int y);
		String getName();
	}
	
	class WhitePawn implements CheckMove {

		@Override
		public boolean canGo(int x1, int y1, int x2, int y2) {
			return y1 > 0 && x1 == x2 && (y1 + 1 == y2 || y1 == 1 && y1 + 2 == y2);
		}

		@Override
		public String getName() {
			return "white pawn";
		}

		@Override
		public boolean canBe(int x, int y) {
			return y > 0;
		}
		
	}
	
	class BlackPawn implements CheckMove {

		@Override
		public boolean canGo(int x1, int y1, int x2, int y2) {
			return y1 < 7 && x1 == x2 && (y1 - 1 == y2 || y1 == 6 && y1 - 2 == y2);
		}

		@Override
		public String getName() {
			return "black pawn";
		}

		@Override
		public boolean canBe(int x, int y) {
			return y < 7;
		}
		
	}
	
	class Knight implements CheckMove {

		@Override
		public boolean canGo(int x1, int y1, int x2, int y2) {
			return Math.abs(x1 - x2) == 2 && Math.abs(y1 - y2) == 1 || Math.abs(x1 - x2) == 1 && Math.abs(y1 - y2) == 2; 
		}

		@Override
		public String getName() {
			return "knight";
		}

		@Override
		public boolean canBe(int x, int y) {
			return true;
		}
		
	}
	
	class Bishop implements CheckMove {
		@Override
		public boolean canGo(int x1, int y1, int x2, int y2) {
			return x1 + y1 == x2 + y2 || x1 - y1 == x2 - y2;
		}

		@Override
		public String getName() {
			return "bishop";
		}

		@Override
		public boolean canBe(int x, int y) {
			return true;
		}
	}
	
	class Rook implements CheckMove {
		@Override
		public boolean canGo(int x1, int y1, int x2, int y2) {
			return x1 == x2 || y1 == y2;
		}

		@Override
		public String getName() {
			return "rook";
		}

		@Override
		public boolean canBe(int x, int y) {
			return true;
		}
	}
	
	class Queen implements CheckMove {

		@Override
		public boolean canGo(int x1, int y1, int x2, int y2) {
			return x1 == x2 || y1 == y2 || x1 + y1 == x2 + y2 || x1 - y1 == x2 - y2;
		}

		@Override
		public String getName() {
			return "queen";
		}

		@Override
		public boolean canBe(int x, int y) {
			return true;
		}
		
	}
	
	class King implements CheckMove {

		@Override
		public boolean canGo(int x1, int y1, int x2, int y2) {
			return Math.abs(x1 - x2) <= 1 && Math.abs(y1 - y2) <= 1 && (x1 != x2 || y1 != y2);
		}

		@Override
		public String getName() {
			return "king";
		}

		@Override
		public boolean canBe(int x, int y) {
			return true;
		}
	}
	
	final String FILE_NAME = "chess";

	SimpleScanner in;
	PrintWriter out;

	@Override
	public void run() {
		try {
			in = new SimpleScanner(new FileReader(FILE_NAME + ".in"));
			out = new PrintWriter(FILE_NAME + ".out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

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

	class SimpleScanner extends BufferedReader {

		private StringTokenizer st;
		private boolean eof;

		public SimpleScanner(Reader a) {
			super(a);
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(readLine());
				} catch (Exception e) {
					eof = true;
					return "";
				}
			}
			return st.nextToken();
		}

		boolean seekEof() {
			String s = next();
			if ("".equals(s) && eof)
				return true;
			st = new StringTokenizer(s + " " + st.toString());
			return false;
		}

		private String cnv(String s) {
			if (s.length() == 0)
				return "0";
			return s;
		}

		int nextInt() {
			return Integer.parseInt(cnv(next()));
		}

		double nextDouble() {
			return Double.parseDouble(cnv(next()));
		}

		long nextLong() {
			return Long.parseLong(cnv(next()));
		}
	}
}