XOR, Tree, and Queries

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

문제

You are given a tree of nn vertices. The vertices are numbered from 11 to nn.

You will need to assign a weight to each edge. Let the weight of the ii-th edge be a_ia\_i (1in11 \leq i \leq n-1). The weight of each edge should be an integer between 00 and 23012^{30}-1, inclusive.

You are given qq conditions. Each condition consists of three integers uu, vv, and xx. This means that the Bitwise XOR of all edges on the shortest path from uu to vv should be xx.

Find out if there exist a_1,a_2,,a_n1a\_1, a\_2, \ldots, a\_{n-1} that satisfy the given conditions. If yes, print a solution such that a_1a_2a_n1a\_1 \oplus a\_2 \oplus \ldots \oplus a\_{n-1} is the smallest. Here, \oplus denotes the bitwise XOR operation.

If there are multiple solutions such that a_1a_2a_n1a\_1 \oplus a\_2 \oplus \ldots \oplus a\_{n-1} is the smallest, print any.

입력

The first line contains two integers nn and qq (2n2.51052 \le n \le 2.5 \cdot 10^5, 0q2.51050 \le q \le 2.5 \cdot 10^5).

The ii-th of the following n1n-1 lines contains two integers x_ix\_i and y_iy\_i (1x_i,y_in1 \le x\_i, y\_i \le n, x_iy_ix\_i \neq y\_i), meaning that the ii-th edge connects vertices x_ix\_i and y_iy\_i in the tree.

It is guaranteed that the given edges form a tree.

The following qq lines contain information about conditions.

Each line contains three integers uu, vv, xx (1u,vn1 \le u, v \le n, uvu \neq v, 0x23010 \le x \le 2^{30}-1), meaning that the bitwise XOR of all edges on the shortest path from uu to vv should be xx.

출력

If there do not exist a_1,a_2,,a_n1a\_1, a\_2, \ldots, a\_{n-1} that satisfy the given conditions, print "No".

Otherwise, print "Yes" in the first line.

Then print n1n-1 integers on the next line, where the ii-th integer is the weight of the ii-th edge. If there are multiple solutions that satisfy the given conditions, print a solution such that a_1a_2a_n1a\_1 \oplus a\_2 \oplus \ldots \oplus a\_{n-1} is the smallest.

If there are multiple solutions such that a_1a_2a_n1a\_1 \oplus a\_2 \oplus \ldots \oplus a\_{n-1} is the smallest, print any.

When printing "Yes" or "No", you can print each letter in any case (either upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.