{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eWe consider only special type of tournaments. Each tournament consists of a series of matches. We have \u003ci\u003en\u003c/i\u003e competitors at the beginning of a competition and after each match the loser is moved out of the competition and the winner stays in (there are no draws). The tournament ends when there is only one participant left - the winner. It is a task of National Sports Federation to schedule the matches. Members of this committee can pick the contestants for the first match. Then, after they know the result, they say which of the remaining contestants meet in the second match, and so on until there is only one participant left.\u003c/p\u003e\r\n\u003cp\u003eIt is easy to see that not only skill and training decides about the win, but also \"luck\" - i.e. the schedule. The members of NSF know it as well.\u003c/p\u003e\r\n\u003cp\u003eThe committee used the training time to look carefully on the performance of each probable contestant. It is clear now, at the start of the season, that some of the results between the competitors are 100% predictable. Having this information NSF considers if it is possible to schedule the matches in such a way that the given contestant \u003cb\u003ex\u003c/b\u003e wins. That is to plan the matches for \u003cb\u003ex\u003c/b\u003e only with those who will lose with him (then he wins the whole tournament of course). If it is possible then w say that \u003cb\u003ethe tournament can be set for x\u003c/b\u003e.\u003c/p\u003e\r\n\u003ch3\u003eTask\u003c/h3\u003e\r\n\u003cp\u003eYour task is to write a program which determines the number of contestants of a given tournament for which it is possible to set it.\u003c/p\u003e\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003e\r\nt [number of tests to solve].\r\n\u003cbr\u003e\r\nIn the first line of each test:\r\nn (1\u0026lt;\u003dn\u0026lt;\u003d1000) - the number of participants of the tournament. We number the participants with numbers 1, 2 ... n.\r\nThe following line contains a list of participants who will inevitably win with participant 1. This list begins with a number \u003ci\u003em\u003c/i\u003e (the number of contestants \"better\" than 1) and numbers n\u003csub\u003e1\u003c/sub\u003e, n\u003csub\u003e2\u003c/sub\u003e ... n\u003csub\u003em\u003c/sub\u003e\r\ndelimited by single spaces. \u003cbr\u003e\r\nNext \u003ci\u003en-1\u003c/i\u003e lines contain analogous lists for participants 2, 3 ... n.\u003c/p\u003e\r\n\u003cp\u003eRemark 1. The fact that participant \u003cb\u003ea\u003c/b\u003e would lose with \u003cb\u003eb\u003c/b\u003e and \u003cb\u003eb\u003c/b\u003e would lose with \u003cb\u003ec\u003c/b\u003e doesn\u0027t necessarily mean that \u003cb\u003ea\u003c/b\u003e would lose with \u003cb\u003ec\u003c/b\u003e in a direct match.\u003c/p\u003e\r\n\u003cp\u003eRemark 2. It is not possible that \u003cb\u003ea\u003c/b\u003e is on the list of contestants better than \u003cb\u003eb\u003c/b\u003e and \u003cb\u003eb\u003c/b\u003e is on the list of \u003cb\u003ea\u003c/b\u003e at the same time.\u003c/p\u003e\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eFor each test your program should output a single integer - the number of participants, for which it is possible to set the tournament.\u003c/p\u003e\r\n\u003ch3\u003eExample\u003c/h3\u003e\r\n\u003cpre\u003e\r\nInput:\r\n1\r\n3\r\n2 3 2\r\n1 3\r\n0\r\n\r\nOutput:\r\n1\r\n\u003c/pre\u003e\r\n\n\u003c/div\u003e"}}]}