{"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\"\u003e There is a tree,there is a life.Can you solve this problem about tree?\u003cbr\u003e Here we have a tree which has n vertices.\u003cbr\u003e We define dist(u, v) as the number of edges on the path from u to v.\u003cbr\u003e And for each vertices u , define E\u003csub\u003eu\u003c/sub\u003e \u003d\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/cadb02c2b1cb2847dec9865c0f9ed175?v\u003d1714331368\"\u003e\u003cbr\u003e Give you the tree and k.\u003cbr\u003e Print E\u003csub\u003ei\u003c/sub\u003e for every vertices(from 1 to n).(mod 10007 for convenience).\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":" The \u0026#xc;first line contains integer T(1 \u0026#x14; T \u0026#x14; 5),denote the number of the test cases.\u003cbr\u003e For each test cases,the first line contains two integers n,k(1\u0026lt;\u003dn\u0026lt;\u003d50000, 1\u0026lt;\u003dk\u0026lt;\u003d500).\u003cbr\u003e Then next n-1 lines,each lines contains two integer a,b(1\u0026lt;\u003da, b\u0026#x14;\u0026lt;\u003dn),denote there is an edge between a, b."}},{"title":"Output","value":{"format":"HTML","content":"For each test cases,print n lines,the i-th line contains E\u003csub\u003ei\u003c/sub\u003e."}},{"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\u003e1\r\n5 3\r\n1 2\r\n2 3\r\n3 4\r\n4 5\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e100\r\n37\r\n18\r\n37\r\n100\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003eThank oimaster for this problem :).\u003cbr\u003e"}}]}