{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"You are given N sets, the i-th set (represent by S(i)) have C(i) element (Here \"set\" isn\u0027t entirely the same as the \"set\" defined in mathematics, and a set may contain two same element). Every element in a set is represented by a positive number from 1 to 10000. Now there are some queries need to answer. A query is to determine whether two given elements i and j belong to at least one set at the same time. In another word, you should determine if there exist a number k (1 \u0026lt;\u003d k \u0026lt;\u003d N) such that element i belongs to S(k) and element j also belong to S(k). "}},{"title":"Input","value":{"format":"HTML","content":"First line of input contains an integer N (1 \u0026lt;\u003d N \u0026lt;\u003d 1000), which represents the amount of sets. Then follow N lines. Each starts with a number C(i) (1 \u0026lt;\u003d C(i) \u0026lt;\u003d 10000), and then C(i) numbers, which are separated with a space, follow to give the element in the set (these C(i) numbers needn\u0027t be different from each other). The N + 2 line contains a number Q (1 \u0026lt;\u003d Q \u0026lt;\u003d 200000), representing the number of queries. Then follow Q lines. Each contains a pair of number i and j (1 \u0026lt;\u003d i, j \u0026lt;\u003d 10000, and i may equal to j), which describe the elements need to be answer."}},{"title":"Output","value":{"format":"HTML","content":"For each query, in a single line, if there exist such a number k, print \"Yes\"; otherwise print \"No\"."}},{"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\u003e3\r\n3 1 2 3\r\n3 1 2 5\r\n1 10\r\n4\r\n1 3\r\n1 5\r\n3 5\r\n1 10\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYes\r\nYes\r\nNo\r\nNo\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":"The input may be large, and the I/O functions (cin/cout) of C++ language may be a little too slow for this problem."}}]}