Under construction

Still being built. Things may change

One-Sided Love

Interview

Time limit2sMemory limit1024 MB

Summary
For each node x other than 1, decide whether two paths from node 1 to x share no node besides 1 and x, and output a binary string.
Level

Medium5 of 10

Topics
Graph, DFS
Solved
No attempts yet

Problem

Today too, the bell rings to end school. Until half a year ago, I waited for this hour with my nose buried in comic books. But at some point, I started to feel regret when this time came. Does she still think I am reading comics? Maybe the warm evening glow on the way home dazzled my eyes, because I wandered off the road. Now I follow behind her in secret.

Problem

You are given an undirected graph. The school is node 11, and her house is at some node other than 11. To avoid being noticed, you must not visit any node she has visited before she reaches her house. For each node, determine whether it is possible to avoid being noticed. That is, find all nodes xx, except node 11, that satisfy the following condition.

  • Among the paths from node 11 to node xx, there exist two paths in which no node other than 11 and xx is shared. The two paths may be identical.

Input

The first line contains the number of nodes NN and the number of edges MM, separated by a space. (2≤N≤500 0002\le N \le 500\,000; 1≤M≤1 000 0001 \le M \le 1\,000\,000)

Each of the next MM lines contains uu and vv, separated by a space. This means nodes uu and vv are connected in both directions. (1≤u,v≤N1 \le u, v \le N; u≠vu \ne v)

Output

The first line prints a binary string of NN digits that marks the nodes satisfying the condition. The ii-th bit from the left is 11 if node ii satisfies the condition, and 00 otherwise. Node 11 is always 00.

Examples2

  1. Example 1

    Input
    9 9
    1 2
    2 3
    3 4
    4 5
    5 1
    2 6
    3 7
    4 8
    5 9
    
    Expected output
    011110000
    
  2. Example 2

    Input
    3 1
    1 2
    
    Expected output
    010