## Problem Description

Liuweixuan and Lucifer are the most two famous acmers in Fuzhou University. Both of them like ddz(dou di zhu).One day lucifer finds another way of playing with pokers. She takes a standard deck of cards (not including the big joker and the small joker), and deal them out into 13 piles of 4 cards each and ask Liuweixuan to do a Selection. The Selection is to find a way to select exactly 1 card from each pile, such that the 13 selected cards contain exactly one card of each rank (ace, 2, 3, ..., queen, king). Liuweixuan is so intelligent that he finds that there always exists a way to finish the Selection. Lucifer is not satisfied with the result and gives Liuweixuan a more difficulty puzzle. The puzzle is to find out how many different ways of Selection he can do from the 13 piles of cards. Liuweixuan is stumped by this puzzle. Can you help him solve this puzzle?

## Input

The first line contains an integer T (T <= 20) representing the number of cases. Then following T cases.

Each case contain 13 lines representing 13 piles of cards.

Each line contains 4 cards. Each card is represented by a two-letter (or digit) word. The first character is the rank (A,K,Q,J,T,9,8,7,6,5,4,3 or 2), the second character is the suit (S,H,D,C standing for spades, hearts, diamonds and clubs).

There may be several blank lines between each input cases.

## Output

For each case output the number of different ways of Selection he can do from the cards.

## Sample Input

1
5S 8C JC 3S
9D JH 4D KS
6S 4C 9S QH
2S QC 6D 9C
TC 2H AD 8S
6H 7C AH AS
5D JD 3H 3D
5C KD KH 2C
7D QD 4S 8H
5H TD 8D TH
JS 7H KC 7S
TS 9H QS 2D
AC 4H 3C 6C

## Sample Output

7124

## Source

FOJ有奖月赛-2009年12月