The first line contains two integers m and r (1≤m≤1000, 1≤r≤1000), the number of cards in Malcolm's hand and the number of cards in Richard's hand.
The second line contains m strings describing the cards in Malcolm's hand. Each card is a colour character, one of R, G, B or Y, followed by a numeric value from 1 to 9.
The third line contains r strings describing the cards in Richard's hand, written in the same format.
The fourth line contains one string describing the card currently on the table, written in the same format.