Yui is a cute girl expert in a kind of game. In case you are not familiar with the game, here we briefly introduce its rules.
is played with
, divided into 34
. To simplify the problem, we assume that
(although in real-world game one kind usually contains up to 4 tiles). The 34 kinds of tiles can be further divided into 4
, named as
, and
. The
have 9 kinds for each suite and
tiles has only 7 kinds.
Here are the all 34 kinds of tiles used in game: Each row refers to a suite of tiles ---
in order.
Minor differences exist in various versions of game, and here we only consider some basic rules.
During the game, each player holds 13 tiles in hand. For each round, one player would draw one tile from the Mahjong table, then discard one tile from one of the 14 tiles owned at the time. A player wins the game if in a round he can create a (defined below) with the 13 tiles in hand and 1 tiles drawn from table or discarded from other player.
A consists of 14 tiles, which can be divided into four \texttt{kezi} or
, and an additional
.
Here, is a set of 3 identical tiles:
Finally, is a pair of identical tiles:
Here are some samples of special combinations:
If the player can obtain a special combination by getting some tile, then we call the player is in the status. In this status one can achieve victory once he/she gets the desired kind of tile!
For example, the following sets of 13 tiles are in the status, the tiles after the space indicates the desired tiles to achieve victory.
Now Yui is playing the game. Sometimes she is very close to victory that if she tosses some tile she would reach the
status, while sometimes such tiles does not yet exist. And sometimes she has already got a winning hand of 14 tiles!
To help you improve your skills, Yui decides to give you a test. Now it is Yui's turn and she has 14 tiles in her hand. Please tell her which tile should be discarded in order to reach
status, or just tell her that she has already won in this round!
The input contains multiple tests cases. The first line includes a single integer
--- the number of test cases. It is guaranteed that
.
Each of the next
lines indicates a test case. It contains a string
of 28 characters, describing the 14 tiles that Yui currently has. For every
, the
-th tile obtained by Yui is described by the
-th and
-th characters in the string: the former is a digit denoting the rank of the tile in its suite and the latter is one of \texttt{w, b, s, z}, which means the suite
and
respectively. It is guaranteed that all the
in the input are valid and legal.
Output the answer for each test case separately. For each test case, if Yui has already reach the winning status in this round, output
in a single line.
Otherwise, output a single integer
in a single line, the number of choices for discarding tiles to reach
status.
Each of the next
lines should indicate one way to reach the
status. It should start with two characters indicating the tile to be discarded. To prove that such way leads to a
status, you should print all the tiles that can lead to victory for the status. For clarity, print a space between the first two characters and the rest of the line.
Pay attention to the order when printing the desired tiles, as there is NO special judge. For tiles in different suites, print them in the order
(that is, always print
tiles at first, and so on). For tiles in the same suite, print the cards in the ascending order of their digits (that is, the tile with smaller number goes first). Additionally, if there are several tiles available for a
status to achieve victory, you should also sort them in the same way. See the Sample Output for details.
The samples are the tiles below: