There is a board of dimension 4 × 3. Each cell of the board is a container that can hold a tile. The board is shown in the following diagram. As expected, you have got 12 tiles with you and you are required to place them in the containers so that every container has one tile in it. However, the tiles that you have are not ordinary tiles. Each tile is a square piece with all its 4 edges colored. A tile is described by its 4 edge colors starting from top and going clockwise. RGBY RGRY YYYY The image shows 3 tiles. The description of the tiles are given below the image. The colors that will be used to denote the tiles will be from the set {yellow, green, blue and red} and will be represented by {Y, G, B and R} for the sake of brevity. There are 12 factorials (12!) ways of placing the tiles on the board. A placement is considered fragile if the touching sides of any two adjacent tiles is made up of different colors. You are required to find out the total number of placements which are not fragile. Note: You can not rotate the tiles. That is, the initial orientation must be preserved. Input The first line of input is an integer T (T < 20) that denotes the number of test cases. Each case starts on a new line and consists of one or more lines containing 12 strings. Each string represents a tile and is made up of 4 characters. Output For each case, output the case number followed by the total number of non-fragile placements.

2/2 Sample Input 2 BBBB BBBB BBBB BBBB BBBB BBBB BBBB BBBB BBBB BBBB BBBB YYYY GGGG GGGG GGGG GGGG GGGG GGGG GGGG GGGG GGGG GGGG GGGG GGGG Sample Output Case 1: 0 Case 2: 479001600