Tichu is a card game for four players. The players sit around a square table, and each player is partnered with the person sitting opposite. The full game uses a standard deck plus four special cards. The essential rule is this: the player who won the previous trick leads a new trick with any legal combination of cards. In turn, each following player may either pass or play the same kind of combination with a strictly higher value. Once everyone passes, the player who played the last combination wins the trick and leads the next one. The overall goal is to get rid of all of your cards as quickly as possible.
Because of this, a good tactic is to arrange your cards so they can be played in as few combinations as possible. For this problem we use a slightly simplified version of the game. We ignore the special cards, leaving a standard deck of 52 cards. Each card has a value from 2 to A (Ace) and one of the suits hearts, diamonds, clubs, or spades. Suits are written with the lowercase letters h, d, c, s, and values in increasing order are 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, A. A card is written as its value followed by its suit, for example Th or 9c.
The legal combinations are:
444KK;89TJQK.You are dealt a hand of 13 distinct cards. Determine the minimum number of legal combinations into which the hand can be partitioned, so that every card belongs to exactly one combination.
(Compared with real Tichu, we have removed consecutive pairs as a legal combination.)
The first line contains a positive integer $T$, the number of test cases ($T \le 100$).
Each of the next $T$ lines describes one hand of 13 cards. The card descriptions are separated by single spaces, and each card is written as its value followed by its suit. All 13 cards in a hand are different.
For each test case, output a single line containing one integer: the minimum number of legal combinations into which the given hand of 13 cards can be partitioned.