Cloud Bridge 2
InterviewTime limit1sMemory limit1024 MB
Color each building so adjacent buildings differ, and among all valid colorings output the one whose color sequence is lexicographically smallest.
Problem
Sunlin Internet High School has several buildings and cloud bridges that connect them.
Specifically, there are buildings numbered through , and cloud bridges, each connecting two distinct buildings.
Jeonghwi, the winner of the 2019 Cheonhajeil Environmental Landscape Design Contest, felt that the colors of the school buildings were too monotonous and that school life was too boring.
So Jeonghwi hired Chaewan, the 2021 winner, to repaint the outer walls of the school buildings. Specifically, Jeonghwi required that the outer walls of the buildings be painted according to the following conditions.
- A color is represented by a positive integer.
- Each building is painted with exactly one color.
- Two buildings connected by a cloud bridge are painted with different colors.
- When the colors of buildings through are listed in order, the sequence is lexicographically smallest.
Tell Chaewan which color to paint the outer wall of each building.
Input
The first line gives and , the number of buildings and the number of cloud bridges.
From the second line, lines follow, each giving the numbers of two distinct buildings connected by a cloud bridge.
Output
Print the color of each building from building to building , separated by spaces, on one line.
Constraints
- A cloud bridge connects two distinct buildings.