Padel Prize Pursuit

아직 제출이 없습니다시간 제한3초메모리 제한1024 MB

문제

There are NN participants numbered 00 to N1N-1 competing in a padel tournament held over MM days. Exactly one match is held each day. There are MM medals handed out in the tournament, a new one for each match. In the match on day ii (0iM1)(0 \le i \le M-1), the two participants numbered x_ix\_i and y_iy\_i are participating. The following happens in the match:

  1. Participant x_ix\_i beats participant y_iy\_i.
  2. A new medal is given to the winner x_ix\_i.
  3. All of the loser's current medals are given to the winner.

On day MM (the day after the last match) the prize ceremony is held. At the ceremony, all medals are collected and then each medal is given to the participant that held that medal the longest. Formally, medal ii is given to the participant who held medal ii for the most nights (not necessarily in a row), as of day MM. If two or more participants have held a medal for the same number of nights, the medal is given to the participant with the smallest index among them.

Your goal is to determine how many medals each participant is awarded at the prize ceremony.

입력

The first line of input contains the integers NN and MM, the number of participants and number of matches.

Then MM lines follow. The iith of these lines contains two integers x_ix\_i and y_iy\_i, the participants competing on day ii, where participant x_ix\_i beats participant y_iy\_i.

출력

On the single line of output print NN integers, the kkth number denoting the number of medals that participant kk has after the prize ceremony.

제한

  • 2N200,0002 \leq N \leq 200\\,000.
  • 1M200,0001 \leq M \leq 200\\,000.
  • 0x_i,y_iN10 \le x\_i, y\_i \le N-1 and x_iy_ix\_i \neq y\_i (for all 0iM10\le i \le M-1).

힌트

For the first sample test case, the following illustration shows who held which medals throughout the tournament. When participant 1 loses on the 3rd day, all her medals are given to participant 2.

The second sample can be seen below.

After the prize ceremony, participant 0 is given medals 5 and 6, participant 1 is given medals 3 and 4, and participant 2 is given medals 0, 1 and 2.