{"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\"\u003eYou are given a rooted tree consisting of $n$ vertices numbered from $1$ to $n$, and the root is vertex $1$. \u003cbr\u003e\u003cbr\u003eVertex $i$ has a natural number weight $a_i$, and $\\textbf{no two different vertexes have the same weight}$. \u003cbr\u003e\u003cbr\u003eDefine $b_u \u003d MEX$ { $x \\space | \\space \\exists v \\in subtree\\left( u \\right), x \u003d a_v\\$}. \u003cbr\u003e\u003cbr\u003eUnfortunately, $a_i$ are not given. Please find out the maximum possible $\\sum_{i\u003d1}^{n}b_i$.\u003cbr\u003e\u003cbr\u003eThe $\\textbf{MEX}$ of a set is the minimum non-negative integer that doesn\u0027t belong to the set.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains one integer $T \\left( 1 \\leq T \\leq 10 \\right)$, indicating the number of test cases.\u003cbr\u003e\u003cbr\u003eFor each test case:\u003cbr\u003e\u003cbr\u003eThe first line contains one integer $n \\left( 1 \\le n \\le 5 \\cdot 10^5 \\right)$, indicating the number of nodes.\u003cbr\u003e\u003cbr\u003eIn the following $n-1$ lines, each line contains two interger $u, v \\left(1 \\le u, v \\le n \\right)$, indicating an edge $\\left( u, v \\right)$ of the tree.\u003cbr\u003e\u003cbr\u003eA guarantee is that forming trees."}},{"title":"Output","value":{"format":"HTML","content":"For each test case:\u003cbr\u003eOne line with an integer, indicating the maximum possible $\\sum_{i\u003d1}^{n}b_i$."}},{"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\u003e3\r\n5\r\n1 2\r\n3 2\r\n1 5\r\n4 1\r\n3\r\n1 2\r\n2 3\r\n1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e8\r\n6\r\n1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}