SP9255 PUBLICAT - Publication

Description

The Orizondo number is a way of describing the "collaborative distance" between a scientist and Rodrigo Orizondo by authorship of scientific publications. Rodrigo Orizondo is the only person who has an Orizondo number equal to zero. To be assigned a finite Orizondo number, a scientist must publish a paper in co-authorship with a scientist with a finite Orizondo number. The Orizondo number of a scientist is the lowest Orizondo number of his coauthors + 1. The order of publications and numbers assignment doesn't matter, i.e., after each publication the list of assigned numbers is updated accordingly. You will be given the **publications**, each element of which describes the list of authors of a single publication and is formatted as "AUTHOR\_1 AUTHOR\_2 ... AUTHOR\_N" (quotes for clarity only). Rodrigo Orizondo will be given as "ORIZONDO". Print out the list of Orizondo numbers which will be assigned to the authors of the listed publications. Each element of the printout should be formatted as "AUTHOR NUMBER" if AUTHOR can be assigned a finite Orizondo number, and just "AUTHOR" otherwise. The authors in the printout list must be ordered lexicographically.

Input Format

The first line of the input gives the number of test cases _C_ (_0 < C )._ Each test case starts with an integer N, the number of publications, then N publications follow. Each publication consists in a space separated list of authors.(each publication in a single line).

Output Format

For each test case, output one line containing each author with his Orizondo Number, all space separated.