{"raw_statement":[{"iden":"statement","content":"Ahmad is one of the best students in HIAST, and also a very good problems Solver. In the time you will spend reading this problem statement Ahmad would have solved a problem. Maybe, even two... Ahmad participated so many times in programming contest (ACM-HCPC) with several teams. many of the former and present contestants at HIAST have known Ahmad for quite a few years. Some of them are proud to say that they either played in the same team with him or played in the same team with one of his teammates... Let us define ranking number as follows. Ahmad's ranking is 0, for people who played in the same team with him, the ranking is 1. For people who never played with Ahmad but played in the same team with one or more of his teammates, the ranking is 2, and so on. Your task is to automate the process of calculating the ranking numbers for each contestant at HIAST.\n\nThe first line of input file contains the number of test cases (0<T<10). Each test case will begin with one line containing the number of teams (1<N ≤ 100). In each of the following N lines you are given the names of the three members of the corresponding team. Each name is a nonempty string contains only English letters starts with capital letter, and its length is at most 20 symbols. Same student can be found in more than one team, but each student should have only one rank. Ahmad will be found in one team at least. The first letter of a name is capital and the other letters are lowercase and each name will consist of only one word.\n\nFor each test case output a line with the number of contestants, then for each contestant output a line with his name and his ranking. If the ranking is undefined, output “undefined” instead of it. The contestants must be ordered by rank from 0 to undefined and then lexicographical by name.\n\n"},{"iden":"input","content":"The first line of input file contains the number of test cases (0<T<10). Each test case will begin with one line containing the number of teams (1<N ≤ 100). In each of the following N lines you are given the names of the three members of the corresponding team. Each name is a nonempty string contains only English letters starts with capital letter, and its length is at most 20 symbols. Same student can be found in more than one team, but each student should have only one rank. Ahmad will be found in one team at least. The first letter of a name is capital and the other letters are lowercase and each name will consist of only one word."},{"iden":"output","content":"For each test case output a line with the number of contestants, then for each contestant output a line with his name and his ranking. If the ranking is undefined, output “undefined” instead of it. The contestants must be ordered by rank from 0 to undefined and then lexicographical by name."},{"iden":"examples","content":"Input21Ahmad Mousaab Khalid7Ahmad Mousaab KhalidAli Mousaab NizarAli Bassel NizarKassem Ahmad MousaabSaeed Kassem FadelSalwa Saeed SamerMona Abdo QussiOutput3Ahmad 0Khalid 1Mousaab 114Ahmad 0Kassem 1Khalid 1Mousaab 1Ali 2Fadel 2Nizar 2Saeed 2Bassel 3Salwa 3Samer 3Abdo undefinedMona undefinedQussi undefined"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ N \\in \\mathbb{Z} $ be the number of days.  \nLet $ K \\in \\mathbb{Z} $ be the number of typos.  \nLet $ T \\in \\mathbb{Z} $ be the error magnitude in hours.  \nFor each day $ i \\in \\{1, \\dots, N\\} $, let the true meeting intervals be $ [a_i, b_i] $ and $ [c_i, d_i] $, with $ 8 \\leq a_i \\leq b_i \\leq 18 $, $ 8 \\leq c_i \\leq d_i \\leq 18 $, and $ a_i \\leq c_i $.  \n\nLet the observed (erroneous) values be $ a_i', b_i', c_i', d_i' $, each of which differs from the true value by at most $ T $ in absolute value, and exactly $ K $ of the $ 4N $ values $ \\{a_i, b_i, c_i, d_i\\}_{i=1}^N $ are erroneous (i.e., differ from their true counterparts by $ \\pm T $).\n\n**Constraints**  \n1. $ 1 \\leq N \\leq 1000 $  \n2. $ 1 \\leq K \\leq 4N $  \n3. $ 1 \\leq T \\leq 10 $  \n4. $ 8 \\leq a_i', b_i', c_i', d_i' \\leq 18 $ for all $ i $  \n5. $ a_i' \\leq b_i' $, $ c_i' \\leq d_i' $, $ a_i' \\leq c_i' $ for all $ i $  \n6. Exactly $ K $ of the 4N values $ a_i', b_i', c_i', d_i' $ differ from their true values by exactly $ \\pm T $; the rest are correct.  \n\n**Objective**  \nRecover any feasible set of true meeting times $ (a_i, b_i, c_i, d_i) $ for all $ i \\in \\{1, \\dots, N\\} $, such that:  \n- Each observed value $ x' \\in \\{a_i', b_i', c_i', d_i'\\} $ satisfies $ |x' - x| \\leq T $,  \n- Exactly $ K $ of the 4N true values $ x $ differ from their observed counterparts by exactly $ T $ (in absolute value),  \n- The true intervals satisfy $ a_i \\leq b_i $, $ c_i \\leq d_i $, $ a_i \\leq c_i $, and $ 8 \\leq a_i, b_i, c_i, d_i \\leq 18 $.  \n\nOutput the true values $ a_i, b_i, c_i, d_i $ for each day $ i $.","simple_statement":"Peter has a busy schedule with two meetings each day for N days.  \nEach meeting has a start and end time.  \nPeter made exactly K typos: each typo changes a time (start or end) by exactly T hours.  \nGiven the incorrect schedule, find any valid original schedule that could have led to it with exactly K typos of T hours each.","has_page_source":false}