atcoder#ABC291E. [ABC291E] Find Permutation

[ABC291E] Find Permutation

Score : 500500 points

Problem Statement

There is a length-NN sequence A=(A1,,AN)A=(A_1,\ldots,A_N) that is a permutation of 1,,N1,\ldots,N.

While you do not know AA, you know that AXiforA_{X_i} for Mpairsofintegers pairs of integers (X_i,Y_i)$.

Can AA be uniquely determined? If it is possible, find AA.

Constraints

  • 2N2×1052 \leq N \leq 2\times 10^5
  • 1M2×1051 \leq M \leq 2\times 10^5
  • 1Xi,YiN1\leq X_i,Y_i \leq N
  • All values in the input are integers.
  • There is an AA consistent with the input.

Input

The input is given from Standard Input in the following format:

NN MM

X1X_1 Y1Y_1

\vdots

XMX_M YMY_M

Output

If AA can be uniquely determined, print Yes in the first line. Then, print A1,,ANA_1,\ldots,A_N in the second line, separated by spaces.

If AA cannot be uniquely determined, just print No.

3 2
3 1
2 3
Yes
3 1 2

We can uniquely determine that A=(3,1,2)A=(3,1,2).

3 2
3 1
3 2
No

Two sequences (2,3,1)(2,3,1) and (3,2,1)(3,2,1) can be AA.

4 6
1 2
1 2
2 3
2 3
3 4
3 4
Yes
1 2 3 4