Problem E
Mengi
Languages
en
is
News have spread of a competition to be held within the university, one centered around the board game Mengi. Someone has to make sure that every move made is legal and there isn’t enough manpower to do so, so a program to find every legal move given a particular board state has to be made.
The game is played with $12$ cards on the table at any given time. The players have to find $3$ cards that together make a Mengi. Each card has $4$ properties. The first property is colour, which can be red (R), blue (B) or green (G). Next is the number of shapes on the card which can be one ($1$), two ($2$) or three ($3$). Next is the shape on the card which can be diamonds (D), ellipses (E) or squares (S). Finally there is the background which can be full colour (F), half colour (H) or transparent (T).
Cards will be represented with colour first, next number, then shape and finally background. As an example R2ST is a red card with two transparent squares.
Three cards constitute a Mengi if for each of these four properties the cards are either all the same or no two are the same. As an example, the three cards all have to be the same colour or have to be of three different colours, then the same for the other properties. The internal order of the cards does not matter, a permutation of three cards that make up a Mengi is still the same Mengi.
Input
The input contains $12$ lines, each with one card that is on the table. No two cards are identical.
Output
Print one line for each possible Mengi. The cards in each Mengi are to be written in internal alphabetical order and printed together on one line with spaces between the cards. The Mengi themselves should also be ordered alphabetically in the output. If no Mengi can be formed from the cards in the input, print “Engin Mengi” instead.
Sample Input 1 | Sample Output 1 |
---|---|
B3SF G3ET R3DH B1ET G3SF G3DH G2SF R1EH B3EH G2SH B2DH R3SH |
B1ET B2DH B3SF B1ET G2SF R3DH B3EH G3DH R3SH B3SF G3ET R3DH G3DH G3ET G3SF |
Sample Input 2 | Sample Output 2 |
---|---|
G1DH R1DH G3DH B1EH B2DF B3EH R2ST R1DF G2EF G1EF B3SH B2SH |
Engin Mengi |