Good Friends

There are n people in a class. Some of them are good friends. They go out frequently. Given m activities, find out which people are good friends. In this problem, if a set of at least two people attended in at least 20% activities together (possibly with some other people), they’re regarded as good friends. Note that “good friends” should be maximal. That means, if you add another person to the set, they will not be “good friends” anymore. Input The first line contains the number of test cases T (T ≤ 5). Each test case begins with two integers n, m (2 ≤ n ≤ 30, 5 ≤ m ≤ 10, 000), the number of people in the class, and the number of activities. Each of the m lines begins with an integer k (2 ≤ k ≤ n), the number of people attending the activity, then k different integers (1..n) followed. People are numbered 1 to n. Output For each test case, print the number of “good friends” sets in the first line, and then print one line for each set. The numbers in each set should be sorted in increasing order. Sets should be sorted in lexicographical order. Print a blank line after each test case. Sample Input 1 10 10 71234567 7 2 4 5 6 7 9 10 8 1 2 4 5 6 7 9 10 6 2 5 6 7 8 10 6 1 3 4 6 9 10 8 1 2 4 5 6 7 9 10 6123567 6 2 5 6 7 8 10 7 2 5 6 7 8 9 10 8 2 3 4 5 6 7 9 10 Sample Output Case 1: 6 123567 1 2 4 5 6 7 9 10 1346 234567 2 5 6 7 8 10 3 4 6 9 10