{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"Once upon a time there lived a king and he had N sons. And there were N beautiful girls in the kingdom and the king knew about each of his sons which of those girls he did like. The sons of the king were young and light-headed, so it was possible for one son to like several girls. \r\u003cbr\u003e\r\u003cbr\u003eSo the king asked his wizard to find for each of his sons the girl he liked, so that he could marry her. And the king\u0027s wizard did it -- for each son the girl that he could marry was chosen, so that he liked this girl and, of course, each beautiful girl had to marry only one of the king\u0027s sons. \r\u003cbr\u003e\r\u003cbr\u003eHowever, the king looked at the list and said: \"I like the list you have made, but I am not completely satisfied. For each son I would like to know all the girls that he can marry. Of course, after he marries any of those girls, for each other son you must still be able to choose the girl he likes to marry.\" \r\u003cbr\u003e\r\u003cbr\u003eThe problem the king wanted the wizard to solve had become too hard for him. You must save wizard\u0027s head by solving this problem. \r\u003cbr\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains N -- the number of king\u0027s sons (1 \u0026lt;\u003d N \u0026lt;\u003d 2000). Next N lines for each of king\u0027s sons contain the list of the girls he likes: first Ki -- the number of those girls, and then Ki different integer numbers, ranging from 1 to N denoting the girls. The sum of all Ki does not exceed 200000. \r\u003cbr\u003e\r\u003cbr\u003eThe last line of the case contains the original list the wizard had made -- N different integer numbers: for each son the number of the girl he would marry in compliance with this list. It is guaranteed that the list is correct, that is, each son likes the girl he must marry according to this list.\r\u003cbr\u003e\r\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"Output N lines.For each king\u0027s son first print Li -- the number of different girls he likes and can marry so that after his marriage it is possible to marry each of the other king\u0027s sons. After that print Li different integer numbers denoting those girls, in ascending order."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\r\n2 1 2\r\n2 1 2\r\n2 2 3\r\n2 3 4\r\n1 2 3 4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2 1 2\r\n2 1 2\r\n1 3\r\n1 4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"This problem has huge input and output data,use scanf() and printf() instead of cin and cout to read data to avoid time limit exceed. "}}]}