Game SET
题号:NC209998
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

is a real-time card game designed by Marsha Falco in 1974 and published by Set Enterprises in 1991. The deck consists of 81 unique cards that vary in four features across three possibilities for each kind of feature: number of shapes (one, two, or three), shape (diamond, squiggle, or oval), shading (solid, striped, or open), and color (red, green, or purple). Each possible combination of features (e.g. a card with ) appears as a card precisely once in the deck.

In the game, certain combinations of three cards are said to make up a . For each one of the four categories of features --- color, number, shape, and shading --- the three cards must display that feature as a) either all the same, or b) all different. Put another way: For each feature the three cards must avoid having two cards showing one version of the feature and the remaining card showing a different version.

For example,



form a , because the shadings of the three cards are all the same, while the numbers, the colors, and the shapes among the three cards are all different.

There are some special cards which called Wild cards. Some values of a Wild card's features can be wild, i.e they can take any value the player chooses. For example, can be regarded as , or .

You're given unique cards, you need to find any valid . Each card is used at most once.

输入描述:

The first line of the input gives the numbers of test cases, .  test cases follow.
Each test case consists of one line with one integer as described above.
The i-th of the next lines describes the i-th card. It contains four categories features, in the format of . The "*" means wild value for that feature.

There are no identical cards.

.

.

输出描述:

For each test case, print  if they can not make up a ,
otherwise, print , where x is the test case number (starting from 1) and y1 y2 y3 are the indexes of cards (starting from 1) that can make up a . If there are several solutions, output any of them.
示例1

输入

复制
3
3
[three][diamond][solid][red]
[two][*][solid][*]
[two][*][*][red]
5
[one][diamond][open][red]
[two][squiggle][solid][red]
[two][squiggle][*][red]
[two][diamond][solid][red]
[three][diamond][*][red]
6
[one][diamond][open][red]
[two][squiggle][*][green]
[two][squiggle][solid][green]
[two][diamond][solid][green]
[three][diamond][*][red]
[*][*][*][*]

输出

复制
Case #1: -1
Case #2: 1 4 5
Case #3: 1 2 6