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

public class chess_sm_40 {
	interface CanGo {
		boolean canGo(int x1, int y1, int x2, int y2);
	}

	String[] name = {
			"white pawn",
			"black pawn",
			"knight",
			"bishop",
			"rook",
			"queen",
			"king"
	};
	CanGo[] canGo = {
			new CanGo() {

				public boolean canGo(int x1, int y1, int x2, int y2) {
					if (y1 == 1 || x1 != x2) {
						return false;
					}
					if (y1 == 2 && y2 == 4)
						return true;
					return y2 == y1 + 1;
				};
			},
			new CanGo() {
				public boolean canGo(int x1, int y1, int x2, int y2) {
					if (y1 == 8 || x1 != x2) {
						return false;
					}
					if (y1 == 7 && y2 == 5)
						return true;
					return y2 == y1 - 1;
				};
			},
			new CanGo() {
				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);
				};
			},
			new CanGo() {
				public boolean canGo(int x1, int y1, int x2, int y2) {
					return Math.abs(x1 - x2) == Math.abs(y1 - y2);
				};
			},
			new CanGo() {
				public boolean canGo(int x1, int y1, int x2, int y2) {
					return x1 == x2 || y1 == y2;
				};
			},
			new CanGo() {
				public boolean canGo(int x1, int y1, int x2, int y2) {
					return Math.abs(x1 - x2) == Math.abs(y1 - y2) || x1 == x2 || y1 == y2;
				};
			},
			new CanGo() {
				public boolean canGo(int x1, int y1, int x2, int y2) {
					return Math.abs(x1 - x2) <= 1 && Math.abs(y1 - y2) <= 1;
				};
			},

	};

	void solve() throws IOException {
		int n = nextInt();
		if (n > 1)return;
		assert 0 <= n && n <= 1000;
		int[] x = new int[n + 1];
		int[] y = new int[n + 1];
		for (int i = 0; i < y.length; i++) {
			String s = nextToken();
			x[i] = s.charAt(0) - 'a' + 1;
			y[i] = s.charAt(1) - '0';
			assert 1 <= x[i] && x[i] <= 8;
			assert 1 <= y[i] && y[i] <= 8;
			assert i == 0 || x[i] != x[i - 1] || y[i] != y[i - 1];
		}
		ArrayList<String> ans = new ArrayList<String>();
		fori: for (int i = 0; i < name.length; i++) {
			if (i == 0 && y[0] == 1) continue;
			if (i == 1 && y[0] == 8) continue;
			for (int j = 0; j < y.length - 1; j++) {
				if (!canGo[i].canGo(x[j], y[j], x[j + 1], y[j + 1]))
					continue fori;
			}
			ans.add(name[i]);
		}
		assert !ans.isEmpty();
		Collections.shuffle(ans);
		for (String s : ans) {
			out.println(s);
		}
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;

	final String filename = "chess";

	public void run() {
		try {
			br = new BufferedReader(new FileReader(filename + ".in"));
			out = new PrintWriter(filename + ".out");
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	String nextToken() {
		try {
			while (st == null || !st.hasMoreTokens()) {
				String s = br.readLine();
				if (s == null) {
					return null;
				}
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		} catch (IOException e) {
			throw new RuntimeException();
		}
	}

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

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	public static void main(String[] args) {
		new chess_sm_40().run();
	}
}
