{"problem":{"name":"A Gift From the Stars","description":{"content":"A graph with $(k+1)$ vertices and $k$ edges is called a level-$k\\ (k\\geq 2)$ star if and only if: *   it has a vertex that is connected to each of the other $k$ vertices with an edge, and there are n","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc303_e"},"statements":[{"statement_type":"Markdown","content":"A graph with $(k+1)$ vertices and $k$ edges is called a level-$k\\ (k\\geq 2)$ star if and only if:\n\n*   it has a vertex that is connected to each of the other $k$ vertices with an edge, and there are no other edges.\n\nAt first, Takahashi had a graph consisting of stars. He repeated the following operation until every pair of vertices in the graph was connected:\n\n*   choose two vertices in the graph. Here, the vertices must be disconnected, and their degrees must be both $1$. Add an edge that connects the chosen two vertices.\n\nHe then arbitrarily assigned an integer from $1$ through $N$ to each of the vertices in the graph after the procedure. The resulting graph is a tree; we call it $T$. $T$ has $(N-1)$ edges, the $i$\\-th of which connects $u_i$ and $v_i$.\nTakahashi has now forgotten the number and levels of the stars that he initially had. Find them, given $T$.\n\n## Constraints\n\n*   $3\\leq N\\leq 2\\times 10^5$\n*   $1\\leq u_i, v_i\\leq N$\n*   The given graph is an $N$\\-vertex tree obtained by the procedure in the problem statement.\n*   All values in the input are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$u_1$ $v_1$\n$\\vdots$\n$u_{N-1}$ $v_{N-1}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc303_e","tags":[],"sample_group":[["6\n1 2\n2 3\n3 4\n4 5\n5 6","2 2\n\nTwo level-$2$ stars yield $T$, as the following figure shows:\n![image](https://img.atcoder.jp/abc303/59ab8e04c23d5f727300be7544b1df7e.png)"],["9\n3 9\n7 8\n8 6\n4 6\n4 1\n5 9\n7 3\n5 2","2 2 2"],["20\n8 3\n8 18\n2 19\n8 20\n9 17\n19 7\n8 7\n14 12\n2 15\n14 10\n2 13\n2 16\n2 1\n9 5\n10 15\n14 6\n2 4\n2 11\n5 12","2 3 4 7"]],"created_at":"2026-03-03 11:01:13"}}