{"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\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Discription","value":{"format":"MD","content":"\u003cstyle type\u003d\u0027text/css\u0027\u003e .input, .output {border: 1px solid #888888;} .output {margin-bottom:1em;position:relative;top:-1px;} .output pre,.input pre {background-color:#EFEFEF;line-height:1.25em;margin:0;padding:0.25em;} .title {background-color:#FFFFFF;border-bottom: 1px solid #888888;font-family:arial;font-weight:bold;padding:0.25em;} \u003c/style\u003e \u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027]], displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027]]}\n });\n \u003c/script\u003e\n \u003cscript type\u003d\"text/javascript\" async\n src\u003d\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\"\u003e\n \u003c/script\u003e\n\u003cp\u003e给出一个有 $$$n$$$ 个节点的有根树。节点的编号从$$$1$$$ 到 $$$n$$$. 树的根节点编号为$$$1$$$.\u003c/p\u003e\n\u003cp\u003e一棵数是具有$$$n-1$$$条边的无向联通图。\u003c/p\u003e\n\u003cp\u003e给出 $$$m$$$ 个询问. 第$$$i$$$个询问由 $$$k_i$$$ 个不同的节 $$$v_i[1], v_i[2], \\dots, v_i[k_i]$$$组成. 你的任务是判断是否存在一条从跟节点到 $$$u$$$的路径,使得给出的 $$$k$$$ 个节点要么在这条路径上,要么与路径上的某个节点距离为$$$1$$$。\u003c/p\u003e"}},{"title":"输入","value":{"format":"MD","content":"\u003cp\u003eThe first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$, $$$1 \\le m \\le 2 \\cdot 10^5$$$) — the number of vertices in the tree and the number of queries.\u003c/p\u003e\n\u003cp\u003eEach of the next $$$n-1$$$ lines describes an edge of the tree. Edge $$$i$$$ is denoted by two integers $$$u_i$$$ and $$$v_i$$$, the labels of vertices it connects $$$(1 \\le u_i, v_i \\le n, u_i \\ne v_i$$$).\u003c/p\u003e\n\u003cp\u003eIt is guaranteed that the given edges form a tree.\u003c/p\u003e\n\u003cp\u003eThe next $$$m$$$ lines describe queries. The $$$i$$$-th line describes the $$$i$$$-th query and starts with the integer $$$k_i$$$ ($$$1 \\le k_i \\le n$$$) — the number of vertices in the current query. Then $$$k_i$$$ integers follow: $$$v_i[1], v_i[2], \\dots, v_i[k_i]$$$ ($$$1 \\le v_i[j] \\le n$$$), where $$$v_i[j]$$$ is the $$$j$$$-th vertex of the $$$i$$$-th query.\u003c/p\u003e\n\u003cp\u003eIt is guaranteed that all vertices in a single query are distinct.\u003c/p\u003e\n\u003cp\u003eIt is guaranteed that the sum of $$$k_i$$$ does not exceed $$$2 \\cdot 10^5$$$ ($$$\\sum\\limits_{i\u003d1}^{m} k_i \\le 2 \\cdot 10^5$$$).\u003c/p\u003e"}},{"title":"Output","value":{"format":"MD","content":"\u003cp\u003eFor each query, print the answer — \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e\", if there is a path from the root to some vertex $$$u$$$ such that each of the given $$$k$$$ vertices is either belongs to this path or has the distance $$$1$$$ to some vertex of this path and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eNO\u003c/span\u003e\" otherwise.\u003c/p\u003e"}},{"title":"Example","value":{"format":"MD","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e10 6\n1 2\n1 3\n1 4\n2 5\n2 6\n3 7\n7 8\n7 9\n9 10\n4 3 8 9 10\n3 2 4 6\n3 2 1 5\n3 4 8 2\n2 6 10\n3 5 4 7\n\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003eYES\nYES\nYES\nYES\nNO\nNO\n\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"MD","content":"\u003cp\u003eThe picture corresponding to the example:\u003c/p\u003e\n\u003cp\u003e\u003cimg class\u003d\"tex-graphics\" SRC\u003d\"CDN_BASE_URL/18639922059e18ed0b524093235a3713?v\u003d1585241218\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/p\u003e\n\u003cp\u003eConsider the queries.\u003c/p\u003e\n\u003cp\u003eThe first query is $$$[3, 8, 9, 10]$$$. The answer is \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e\" as you can choose the path from the root $$$1$$$ to the vertex $$$u\u003d10$$$. Then vertices $$$[3, 9, 10]$$$ belong to the path from $$$1$$$ to $$$10$$$ and the vertex $$$8$$$ has distance $$$1$$$ to the vertex $$$7$$$ which also belongs to this path.\u003c/p\u003e\n\u003cp\u003eThe second query is $$$[2, 4, 6]$$$. The answer is \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e\" as you can choose the path to the vertex $$$u\u003d2$$$. Then the vertex $$$4$$$ has distance $$$1$$$ to the vertex $$$1$$$ which belongs to this path and the vertex $$$6$$$ has distance $$$1$$$ to the vertex $$$2$$$ which belongs to this path.\u003c/p\u003e\n\u003cp\u003eThe third query is $$$[2, 1, 5]$$$. The answer is \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e\" as you can choose the path to the vertex $$$u\u003d5$$$ and all vertices of the query belong to this path.\u003c/p\u003e\n\u003cp\u003eThe fourth query is $$$[4, 8, 2]$$$. The answer is \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e\" as you can choose the path to the vertex $$$u\u003d9$$$ so vertices $$$2$$$ and $$$4$$$ both have distance $$$1$$$ to the vertex $$$1$$$ which belongs to this path and the vertex $$$8$$$ has distance $$$1$$$ to the vertex $$$7$$$ which belongs to this path.\u003c/p\u003e\n\u003cp\u003eThe fifth and the sixth queries both have answer \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eNO\u003c/span\u003e\" because you cannot choose suitable vertex $$$u$$$.\u003c/p\u003e"}}]}