GamesAreUs.com has just finished this year's external audit. One finding was the absence of any business rules for assigning file permissions on the company's shared file server. The analysts are defining roles for all employees and the permissions each role should receive. Your team should study the current situation and provide input.
Fortunately, permission assignment has not been entirely random. The most common way to onboard a new employee is to request access "just like Joe", effectively creating an ad-hoc prototype system.
You are given the access control lists (ACLs) for the top-level directories of the shared file server. Using them, write a program that splits the users into equivalence classes so that all members of a class have access to exactly the same set of directories.
Because GamesAreUs.com has several departments, there are multiple sets of ACLs to process: one set of lists per department.
The first line contains a single integer $n$ ($0 < n < 100$), alone on its line with no surrounding whitespace, giving the number of departments. The data for the departments follow.
The ACLs of one department form a sequence of ACL lines terminated by a line containing only -1. Each ACL is a line of unsigned integers ($1 \le x \le 2147483647$) separated by single spaces. The first integer on the line is the file id (FID) of a directory; the remaining integers are the user ids (UIDs) that have access. Every line has a FID and at least one UID. A line contains no duplicate UIDs, but UIDs and FIDs live in separate namespaces, so a UID may be the same integer as a FID. The ACLs, and the UIDs within an ACL, appear in no particular order. Across all ACLs of a department, a given FID appears only once. There are at most 50 top-level directory ACLs and at most 100 UIDs. All FIDs and UIDs are positive.
For each department, the first output line identifies which case is being processed, numbered from 1. That line contains the word Case, one space, and the integer identifying the case.
Then, for every class with at least 2 members, print a line with the number of members in the class (no sign or leading zeros), one space, and the smallest UID in the class (no sign, leading zeros, or trailing spaces). Sort these lines by the number of members in descending order, and then by the UID in ascending order. If there are no such classes, print no prototypes found.