{"problem":{"name":"C. Andryusha and Colored Balloons","description":{"content":"Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he decided to decorate them. The park consists of _n_ squares connected with (_n_ - 1) bidirect","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF782C"},"statements":[{"statement_type":"Markdown","content":"Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he decided to decorate them.\n\nThe park consists of _n_ squares connected with (_n_ - 1) bidirectional paths in such a way that any square is reachable from any other using these paths. Andryusha decided to hang a colored balloon at each of the squares. The baloons' colors are described by positive integers, starting from 1. In order to make the park varicolored, Andryusha wants to choose the colors in a special way. More precisely, he wants to use such colors that if _a_, _b_ and _c_ are distinct squares that _a_ and _b_ have a direct path between them, and _b_ and _c_ have a direct path between them, then balloon colors on these three squares are distinct.\n\nAndryusha wants to use as little different colors as possible. Help him to choose the colors!\n\n## Input\n\nThe first line contains single integer _n_ (3 ≤ _n_ ≤ 2·105) — the number of squares in the park.\n\nEach of the next (_n_ - 1) lines contains two integers _x_ and _y_ (1 ≤ _x_, _y_ ≤ _n_) — the indices of two squares directly connected by a path.\n\nIt is guaranteed that any square is reachable from any other using the paths.\n\n## Output\n\nIn the first line print single integer _k_ — the minimum number of colors Andryusha has to use.\n\nIn the second line print _n_ integers, the _i_\\-th of them should be equal to the balloon color on the _i_\\-th square. Each of these numbers should be within range from 1 to _k_.\n\n[samples]\n\n## Note\n\nIn the first sample the park consists of three squares: 1 → 3 → 2. Thus, the balloon colors have to be distinct.\n\n<center>![image](https://espresso.codeforces.com/2ff653f32bfeefaf0fd3028981bd2d53dc4b30f6.png) Illustration for the first sample.</center>In the second example there are following triples of consequently connected squares:\n\n*   1 → 3 → 2\n*   1 → 3 → 4\n*   1 → 3 → 5\n*   2 → 3 → 4\n*   2 → 3 → 5\n*   4 → 3 → 5\n\nWe can see that each pair of squares is encountered in some triple, so all colors have to be distinct.<center>![image](https://espresso.codeforces.com/a7848c3533ce6126dcfebb18b1205cbeb946a885.png) Illustration for the second sample.</center>In the third example there are following triples:\n\n*   1 → 2 → 3\n*   2 → 3 → 4\n*   3 → 4 → 5\n\nWe can see that one or two colors is not enough, but there is an answer that uses three colors only.<center>![image](https://espresso.codeforces.com/56b03c0b57412feb7b6b81122b439709cce143fd.png) Illustration for the third sample.</center>","is_translate":false,"language":"English"}],"meta":{"iden":"CF782C","tags":["dfs and similar","graphs","greedy","trees"],"sample_group":[["3\n2 3\n1 3","3\n1 3 2"],["5\n2 3\n5 3\n4 3\n1 3","5\n1 3 2 5 4"],["5\n2 1\n3 2\n4 3\n5 4","3\n1 2 3 1 2"]],"created_at":"2026-03-03 11:00:39"}}