{"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":"","value":{"format":"HTML","content":"\u003cp\u003eYou are given a rooted tree consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root of the tree is a vertex number $$$1$$$.\u003c/p\u003e\n\u003cp\u003eA tree is a connected undirected graph with $$$n-1$$$ edges.\u003c/p\u003e\n\u003cp\u003eYou are given $$$m$$$ queries. The $$$i$$$-th query consists of the set of $$$k_i$$$ distinct vertices $$$v_i[1], v_i[2], \\dots, v_i[k_i]$$$. Your task is to say 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.\u003c/p\u003e\n给出一个有n个顶点的有根树,顶点的编号从1到n。树的根节点编号恒为1。\n一棵数是具有n-1条边的联通图。\n给出 m 个询问。第i个询问由 k_i 个不同的节点 $v_i[1], v_i[2], …, v_i[k_i]$组成. 你的任务是判断是否存在一条从根节点到u的路径,使得给出的k_i个节点要么在这条路径上,要么与该路径上的某个节点距离为1。"}},{"title":"Input","value":{"format":"HTML","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":"HTML","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":"Sample 1","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\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\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\nYES\nYES\nYES\nNO\nNO\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","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\u003d1648482921\" 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"}}]}