{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eMiao draws an unrooted tree with n nodes on a piece of paper.\u003c/p\u003e\n\u003cp\u003eThen he picks some random points on the tree and wants to know if these points are on a chain of the tree.\u003c/p\u003e\n\u003cp\u003eFor example, in the figure below, $\\{1, 2, 4\\}, \\{1, 4, 5\\}, \\{3, 2, 5\\}, \\{3, 5, 2\\}$ are all on the same chain, and $\\{1, 3, 4\\}, \\{1, 2, 3, 4\\}, \\{1, 2, 3, 4, 5\\}$ are not on the same chain.\u003c/p\u003e\n\u003ccenter\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/8fe0db1a43af85f8662ddde054102bce?v\u003d1660449170\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\" width\u003d\"189px\"\u003e\n\u003c/center\u003e\n\u003cp\u003eNow Miao gives this problem to you and wants you to help him solve it. \u003c/p\u003e\n\u003cp\u003eHe will give you some points for each query, and you only need to answer him whether these points are on the same chain. If they are on the same chain, output \"YES\", otherwise output \"NO\".\u003cp\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line has a positive integer $n(1 \\leq n \\leq 2*10^5)$, the number of points in the tree.\u003c/p\u003e\n\u003cp\u003eThe following $n - 1$ rows have two positive integers $u_i, v_i (1 \\leq u_i, v_i \\leq n)$ in each row, and $u_i, v_i$ are connected by an edge.\u003c/p\u003e\n\u003cp\u003eThe following line has a positive integer $q(1 \\leq 10^5)$ that asks for the number.\u003c/p\u003e\n\u003cp\u003eThen there are $2 * q$ rows.\u003c/p\u003e\n\u003cp\u003eThe first line a positive integer $k(1 \\leq k \\leq n)$, the number of points in the current query.\u003c/p\u003e\n\u003cp\u003eThe second line has $k$ distinct numbers $a_1, a_2, ... ,a_k$, all points of the current query.\u003c/p\u003e\n\u003cp\u003eIt is guaranteed that the sum of k does not exceed $2*10^5$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"Each query outputs one line, if all points are in the same chain, 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\u003e5\n1 2\n2 3\n2 4\n4 5\n5\n3\n3 2 5\n5\n1 2 3 4 5\n2\n1 4\n3\n1 3 5\n3\n1 5 4\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\nNO\nYES\nNO\nYES\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}