{"trustable":true,"prependHtml":"\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 async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eByteasar has a tree $T$ with $n$ vertices conveniently labeled with $1,2,...,n$. Each vertex of the tree has an integer value $v_i$.\u003cbr\u003e\u003cbr\u003eThe value of a non-empty tree $T$ is equal to $v_1\\oplus v_2\\oplus ...\\oplus v_n$, where $\\oplus$ denotes bitwise-xor.\u003cbr\u003e\u003cbr\u003eNow for every integer $k$ from $[0,m)$, please calculate the number of non-empty subtree of $T$ which value are equal to $k$.\u003cbr\u003e\u003cbr\u003eA subtree of $T$ is a subgraph of $T$ that is also a tree.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains an integer $T(1\\leq T\\leq10)$, denoting the number of test cases.\u003cbr\u003e\u003cbr\u003eIn each test case, the first line of the input contains two integers $n(n\\leq 1000)$ and $m(1\\leq m\\leq 2^{10})$, denoting the size of the tree $T$ and the upper-bound of $v$.\u003cbr\u003e\u003cbr\u003eThe second line of the input contains $n$ integers $v_1,v_2,v_3,...,v_n(0\\leq v_i \u0026lt; m)$, denoting the value of each node.\u003cbr\u003e\u003cbr\u003eEach of the following $n-1$ lines contains two integers $a_i,b_i$, denoting an edge between vertices $a_i$ and $b_i(1\\leq a_i,b_i\\leq n)$.\u003cbr\u003e\u003cbr\u003eIt is guaranteed that $m$ can be represent as $2^k$, where $k$ is a non-negative integer."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print a line with $m$ integers, the $i$-th number denotes the number of non-empty subtree of $T$ which value are equal to $i$.\u003cbr\u003e\u003cbr\u003eThe answer is huge, so please module $10^9+7$."}},{"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\r\n4 4\r\n2 0 1 3\r\n1 2\r\n1 3\r\n1 4\r\n4 4\r\n0 1 3 1\r\n1 2\r\n1 3\r\n1 4\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3 3 2 3\r\n2 4 2 3\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}