{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"Tom and Jerry like to draw trees. One day Tom drew a tree, and soon he found another tree drawn by Jerry. He thinks that Jerry has copied his tree and added some nodes and edges, and for safety he may have changed the label of the nodes (but not the root). So, Tom asks your help.\n\nA tree is a connected graph with no cycles. They both drew rooted trees, now your task is to find whether Jerry has modified Tom\u0027s tree or not."}},{"title":"Input","value":{"format":"MD","content":"Input starts with an integer **T (\u0026le; 50)**, denoting the number of test cases.\n\nEach case starts with a line containing an integer **n (2 \u0026le; n \u0026le; 100)** denoting the number of nodes in Jerry\u0027s tree. Each of the next **n-1** lines contains two integers **u\u003csub\u003ei\u003c/sub\u003e v\u003csub\u003ei\u003c/sub\u003e (1 \u0026le; u\u003csub\u003ei\u003c/sub\u003e, v\u003csub\u003ei\u003c/sub\u003e \u0026le; n, u\u003csub\u003ei\u003c/sub\u003e \u0026ne; v\u003csub\u003ei\u003c/sub\u003e)** denoting that there is an edge between **u\u003csub\u003ei\u003c/sub\u003e** and **v\u003csub\u003ei\u003c/sub\u003e** in Jerry\u0027s tree.\n\nThe next line contains an integer **m (1 \u0026le; m \u0026lt; n)** denoting the number of nodes in Tom\u0027s tree. Each of the next **m-1** lines contains two integers **p\u003csub\u003ei\u003c/sub\u003e q\u003csub\u003ei\u003c/sub\u003e (1 \u0026le; p\u003csub\u003ei\u003c/sub\u003e, q\u003csub\u003ei\u003c/sub\u003e \u0026le; m, p\u003csub\u003ei\u003c/sub\u003e \u0026ne; q\u003csub\u003ei\u003c/sub\u003e)** denoting that there is an edge between **p\u003csub\u003ei\u003c/sub\u003e** and **q\u003csub\u003ei\u003c/sub\u003e** in Tom\u0027s tree.\n\nFor both trees, **1** is the root."}},{"title":"Output","value":{"format":"MD","content":"For each case, print the case number and `Yes` if Jerry has modified Tom\u0027s tree or `No` otherwise."}},{"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\u003e2\n4\n1 2\n2 4\n1 3\n3\n1 3\n3 2\n5\n1 2\n2 4\n1 3\n3 5\n4\n1 3\n1 2\n1 4\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1: Yes\nCase 2: No\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}