// Arup Guha
// 4/11/2017
// Solution to 1992 UCF HS Contest Problem: Trooji

import java.util.*;

public class trooji {

	// For each 2 x 2 shape store the one cell that's missing.
	final public static int[] MISSINGX = {0,0,1,1};
	final public static int[] MISSINGY = {1,0,1,0};

	final public static int N = 8;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		// Process each case.
		while (stdin.hasNext()) {

			// Leave a buffer for the drop of 2 extra rows.
			boolean[][] grid = new boolean[N+2][N];

			// Get the number of moves.
			int numMoves = stdin.nextInt();

			// Process each move.
			for (int i=1; i<=numMoves; i++) {

				// Read input and convert it to our designated storage.
				String pStr = stdin.next();
				int piece = pStr.charAt(0) - 'A';
				int col = stdin.nextInt() - 1;

				// Process this move.
				boolean res = process(grid, piece, col);

				// Output if we need to.
				if (!res) System.out.println("Reject piece "+i+": "+pStr+" "+(col+1));
			}

			// This is nice - after every case.
			System.out.println();
		}
	}

	public static boolean process(boolean[][] grid, int piece, int col) {

		// Initial row.
		int row = N+1;

		// Keep on dropping until we can't.
		while (row >= 1) {
			if (!fits(grid, piece, row, col)) break;
			row--;
		}

		// Move back to correct location.
		row++;

		// Piece is sticking up out of grid.
		if (row >= N) return false;

		// Put this piece in the grid.
		for (int i=0; i<2; i++)
			for (int j=0; j<2; j++)
				if (i != MISSINGX[piece] || j != MISSINGY[piece])
					grid[row-i][col+j] = true;

		// Mark that the move was successful.
		return true;
	}

	public static boolean fits(boolean[][] grid, int piece, int row, int col) {

		// Just see if there's an overlap between this piece at (row, col) - top right and what's in grid.
		for (int i=0; i<2; i++)
			for (int j=0; j<2; j++)
				if ((i != MISSINGX[piece] || j != MISSINGY[piece]) && grid[row-i][col+j])
					return false;

		// If we make it here, there was no overlap.
		return true;
	}
}