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

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

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof = false;

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

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

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

	void myAssert(boolean u, String message) {
		if (!u) {
			throw new Error("Assertion failed!!! " + message);
		}
	}

	int inBounds(int x, int l, int r, String name) {
		myAssert(l <= x && x <= r, name + " is not in bounds: " + x
				+ " not in [" + l + ", " + r + "]");
		return x;
	}

	String FNAME = "chess";

	private void solve() throws IOException {
		int n = inBounds(nextInt(), 1, 1000, "n");
		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';
			y[i] = s.charAt(1) - '1';
			if (i > 0 && x[i] == x[i - 1] && y[i] == y[i - 1]) {
				return;
			}
		}
		Figure[] f = new Figure[] { new WhitePawn(), new BlackPawn(),
				new Knight(), new Bishop(), new Rook(), new Queen(), new King() };
		boolean[] good = new boolean[f.length];
		Arrays.fill(good, true);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < f.length; j++) {
				good[j] &= f[j].checkMove(x[i], y[i], x[i + 1], y[i + 1]);
			}
		}
		for (int i = 0; i < good.length; i++) {
			if (good[i]) {
				out.println(f[i].getName());
			}
		}
	}

	interface Figure {
		public String getName();

		public boolean checkMove(int x1, int y1, int x2, int y2);
	}

	class WhitePawn implements Figure {
		@Override
		public String getName() {
			return "white pawn";
		}

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

	class BlackPawn implements Figure {
		@Override
		public String getName() {
			return "black pawn";
		}

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

	class Knight implements Figure {
		@Override
		public String getName() {
			return "knight";
		}

		@Override
		public boolean checkMove(int x1, int y1, int x2, int y2) {
			return Math.abs(x1 - x2) + Math.abs(y1 - y2) == 3 && x1 != x2
					&& y1 != y2;
		}
	}

	class Bishop implements Figure {
		@Override
		public String getName() {
			return "bishop";
		}

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

	class Rook implements Figure {
		@Override
		public String getName() {
			return "rook";
		}

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

	class Queen implements Figure {
		@Override
		public String getName() {
			return "queen";
		}

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

	class King implements Figure {
		@Override
		public String getName() {
			return "king";
		}

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

}