Look how short the statement is! This must be the easiest problem.
Given a directed acyclic graph $$$G$$$, you need to assign each vertex $$$i$$$ a positive integer weight $$$w_i$$$. Your goal is to make all paths from $$$1$$$ to $$$n$$$ of equal length.
A directed acyclic graph is a graph with directed edges and without cycles.
The length of a path is defined as the sum of the weights of vertices on the path.
The first line contains a positive integer $$$T$$$ ($$$1\le T\le 10^4$$$), denoting the number of test cases.
For each testcase:
It is guaranteed that $$$\sum n\le 2\cdot 10^5$$$, $$$\sum m\le 5\cdot 10^5$$$.
It is guaranteed that the graph contains no multiple edges, no self-loops and no cycles. It is also guaranteed that every vertex is reachable from $$$1$$$ and can reach $$$n$$$.
For each testcase, if there is no solution, then output "No" on a single line. Otherwise, output "Yes" on the first line, then $$$n$$$ positive integers $$$w_1,w_2,\ldots,w_n$$$ ($$$1\le w_i\le 10^9$$$) on the second line.
23 31 21 32 38 91 21 31 42 53 64 75 86 87 8
No Yes 1 1 2 3 3 2 1 1
211 161 21 31 41 52 64 63 74 75 86 82 93 97 108 109 1110 118 101 21 32 43 53 64 62 75 76 87 8
Yes 1 1 1 1 2 1 2 1 3 1 1 No