Under construction

Still being built. Things may change

Water Pipe Game

Time limit1sMemory limit1024 MB

Summary
For each intersection, decide whether the first player wins the game where crews take turns walking along unused road segments.
Level

Hard8 of 10

Topics
Game theory, Graph, DFS
Solved
No attempts yet

Problem

Bajtazar and Bajtoni's plumbing crews won the bid to bring water to Bajtołów Dolny. The road network of this city has nn intersections connected by mm road segments. From every intersection you can reach every other intersection using the road network. A water pipe must be buried under each road segment.

To make their work more interesting, Bajtazar and Bajtoni decided to play a game. At the start, both crews stand at one of the intersections. The two crews move together for the whole game. The players move in turns, starting with Bajtazar. On his turn, a player chooses for his crew a road segment that leaves the intersection where both crews currently are and does not have a pipe under it yet. The crew buries a pipe under that segment, and then both crews move to the other intersection that the segment connects.

A player who cannot make a move loses, and as a punishment, his crew must bury pipes under all the remaining road segments.

Bajtazar wants to know from which intersection the game can start so that he can win no matter how Bajtoni plays. Help him find the list of such intersections.

The road network has a special property. If you leave from the middle of any road segment, there is exactly one way to make a loop and return to the starting point, without ever turning back and without visiting any intersection twice.

Input

The first line contains two integers nn and mm, separated by a single space, the number of intersections and the number of road segments. The intersections are numbered from 1 to nn. Each of the next mm lines contains two integers aa and bb (1≤a,b≤n1 \le a, b \le n, a≠ba \ne b), separated by a single space, meaning that intersections aa and bb are connected by a road segment. You may assume that no two intersections are connected by more than one road segment.

Output

Print exactly nn lines. In the ii-th line, print 1 if Bajtazar can win when the game starts at intersection ii. Otherwise, print 2.

Constraints

3≤n,m≤5000003 \le n, m \le 500000

Examples1

  1. Example 1

    Input
    6 7
    1 2
    2 3
    3 1
    3 4
    4 5
    5 6
    6 3
    
    Expected output
    1
    1
    1
    2
    1
    2