Countdown

Time limit1sMemory limit128 MB

Problem

A genealogy service stores family trees for its clients. A client recently asked a question the software could not answer: "Which member of my family has the most grandchildren?" — along with similar questions about great-grandchildren, great-great-grandchildren, and so on.

For a given family tree and a distance $d$, a person's relevant descendants are the people exactly $d$ generations below them: $d = 1$ means their children, $d = 2$ their grandchildren, $d = 3$ their great-grandchildren, and so on. Find the people with the most relevant descendants.

Input

The first line contains a single integer, the number of test cases.

Each test case begins with a line containing two positive integers $n$ and $d$: $n$ is the number of description lines that follow, and $d$ is the generation distance of the question ($d = 1$ for children, $d = 2$ for grandchildren, and so on).

Each of the next $n$ lines has the form

name m dname1 dname2 ... dnamem

where name is a family member, m is that member's number of children, and dname1 ... dnamem are the children's names. The lines are given in no particular order. Together the $n$ lines describe one single connected tree. A tree has at most 1000 people, and every name is at most 10 characters long.

Output

For each test case, first print the line

Tree i:

where i is the test case number, starting at 1.

Then, among the people who have at least one relevant descendant, order them by their number of relevant descendants (largest first), breaking ties by name in alphabetical order. Print the first three people of this ordering; however, if the third-place count is tied so that more than three people qualify, print every person whose count is at least that third-place count (all people tied at the bottom are included). Print fewer than three names when fewer than three people have any relevant descendants, and print no names at all if nobody does. Give each printed person on their own line as the name, a single space, and the count.

Separate consecutive test cases with a blank line.