Play the game SET
题号:NC202163
时间限制:C/C++/Rust/Pascal 15秒,其他语言30秒
空间限制: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, oval), shading (solid, striped, or open), and color (red, green, or purple). Each possible combination of features (e.g. a card with [three][striped][green][diamonds]) 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,
[three][solid][red][diamonds]
[two][solid][green][squiggles]
[one][solid][purple][oval]

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.

You're given unique cards, you need to form them into sets. You need to output the maximum number of sets with the given cards, and 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 ``[*][*][*][*]''

There are no identical cards.
.
.
There are at most 10 test cases have .

输出描述:

For each test case, the first line print "Case #x: y", where x is the test case number (starting from 1) and y is the maximum number of sets. Then print y triples , , , defining the indexes of cards (starting from 1) that can make up a . If there are several solutions, output any of them.
示例1

输入

复制
1
7
[one][diamond][solid][red]
[two][diamond][solid][red]
[three][diamond][solid][red]
[one][diamond][solid][green]
[one][diamond][solid][purple]
[two][diamond][solid][purple]
[purple][three][diamond][solid]

输出

复制
Case #1: 2
1 2 3
5 6 7