Under construction

Still being built. Things may change

Network

Time limit2.5sMemory limit1024 MB

Summary
For each link, count the computers whose removal disconnects the network after that link is deleted, and print one count per link.
Level

Medium7 of 10

Topics
Graph, DFS, Tree
Solved
No attempts yet

Problem

A network is made of NN computers and MM links. The computers are numbered from 11 to NN. Each link lets two different computers communicate in both directions. A network is connected if any two of its computers can communicate using one or more links. If there is a pair of computers that cannot communicate, the network is disconnected.

The danger level of a link cc is defined as follows.

  • For each computer ii in the network, if the remaining network is disconnected after removing computer ii, computer ii is called a dangerous computer.
  • The danger level of cc is the number of dangerous computers in the initial network after removing cc.

Input

The first line contains two integers NN and MM. (2≤N≤250 0002 \le N \le 250\,000, 1≤M≤1 000 0001 \le M \le 1\,000\,000)

Each of the next MM lines contains xix_i and yiy_i. Link ii connects computer xix_i and computer yiy_i. (1≤xi,yi≤N1 \le x_i, y_i \le N, xi≠yix_i \neq y_i)

Output

Print MM lines. The ii-th line is the danger level of link ii.

Constraints

  • 2≤N≤250 0002 \le N \le 250\,000
  • 1≤M≤1 000 0001 \le M \le 1\,000\,000
  • Each link connects two different computers.
  • Multiple links may connect the same pair of computers.
  • The initial network is connected.

Examples1

  1. Example 1

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