Given a tree of size $n$ and $m$ simple paths on the tree, you need to assign a color $c_i$ to each path such that no two paths of the same color share any common vertices.
Find the minimum number of colors required and construct a valid assignment.
Input
This problem contains multiple test cases.
The first line of the input contains an integer $c$, representing the subtask number. $c=0$ indicates that the test case is a sample.
The second line of the input contains an integer $t$, representing the number of test cases.
For each test case:
The first line contains two positive integers $n, m$.
The next $n-1$ lines each contain two positive integers $u_i, v_i$, representing the $i$-th edge of the tree as $(u_i, v_i)$.
The next $m$ lines each contain two positive integers $a_i, b_i$, representing the $i$-th path as the simple path from $a_i$ to $b_i$.
Output
For each test case:
The first line contains a positive integer $k$, representing the minimum number of colors required.
The second line contains $m$ positive integers, where the $i$-th number is the color $c_i$ of the $i$-th path. You must ensure $1 \le c_i \le k$.
If your output $k$ is correct and the sequence $c_i$ follows the format but does not satisfy the problem requirements, you will receive $15\%$ of the points for that test case.
Examples
Input 1
0 3 3 3 1 2 2 3 3 2 2 1 2 3 7 4 1 2 1 3 2 4 2 5 5 6 6 7 6 3 3 6 5 2 5 6 10 3 1 2 1 3 1 4 3 5 3 6 5 7 5 8 7 9 1 10 8 3 1 2 6 8
Output 1
3 1 2 3 4 1 2 3 4 2 1 1 2
Constraints
For all data, $1 \le t \le 10^5, 1 \le n, m, \sum n, \sum m \le 5 \times 10^5, 1 \le u_i, v_i, a_i, b_i \le n$.
- Subtask 1 (3 pts): $n, m \le 5$.
- Subtask 2 (14 pts): $m \le 5$.
- Subtask 3 (9 pts): $\forall 1 \le i < n, u_i = i, v_i = i+1$.
- Subtask 4 (20 pts): $n, m \le 1000, \sum n, \sum m \le 5000$.
- Subtask 5 (22 pts): $\sum n, \sum m \le 10^5$.
- Subtask 6 (32 pts): No special constraints.