Problem Statement
You are given a directed graph with N vertices and M edges. For i=1,2,ldots,M, the i-th edge is directed from vertex si to vertex ti.
Determine whether there is a permutation P=(P1,P2,ldots,PN) of (1,2,ldots,N) that satisfies both of the following conditions, and if there is, provide an example.
- PsiltPti for all i=1,2,ldots,M.
- LileqPileqRi for all i=1,2,ldots,N.
Constraints
- 2leqNleq2times105
- $0 \\leq M \\leq \\min\\lbrace 4 \\times 10^5, N(N-1) \\rbrace$
- 1leqsi,tileqN
- sineqti
- ineqjimplies(si,ti)neq(sj,tj)
- 1leqLileqRileqN
- All input values are integers.
The input is given from Standard Input in the following format:
N M
s1 t1
s2 t2
vdots
sM tM
L1 R1
L2 R2
vdots
LN RN
Output
If there is no P that satisfies the conditions, print No
. If there is a P that satisfies the conditions, print Yes
in the first line, and the elements of P separated by spaces in the second line, in the following format. If multiple P's satisfy the conditions, any of them will be accepted.
Yes
P1 P2 ldots PN
5 4
1 5
2 1
2 5
4 3
1 5
1 3
3 4
1 3
4 5
Sample Output 1
Yes
3 1 4 2 5
P=(3,1,4,2,5) satisfies the conditions. In fact,
- for the first edge (s1,t1)=(1,5), we have P1=3lt5=P5;
- for the second edge (s2,t2)=(2,1), we have P2=1lt3=P1;
- for the third edge (s3,t3)=(2,5), we have P2=1lt5=P5;
- for the fourth edge (s4,t4)=(4,3), we have P4=2lt4=P3.
Also,
- L1=1leqP1=3leqR1=5,
- L2=1leqP2=1leqR2=3,
- L3=3leqP3=4leqR3=4,
- L4=1leqP4=2leqR4=3,
- L5=4leqP5=5leqR5=5.
2 2
1 2
2 1
1 2
1 2
Sample Output 2
No
No P satisfies the conditions, so print No
.