The input will consist of one to twelve data sets, followed by a line containing only 0.
The first line of a dataset contains the number, t, of turns reported, 2 ≤ t ≤ 15.
The next line contains four blank separated strings for the hands of players 1, 2, and 3, followed by the cards for the gang.
The remaining t lines of the data set contain the data for each turn in order. Each line contains three blank separated tokens: the number of the player interrogated, the string of interrogation letters, and the answer provided.
All letter strings will contain only capital letters from A to R, in strictly increasing alphabetical order. The same interrogation string may appear in more than one turn of a game.