Problem: You are given a tree of vertices numbered from to , with edges numbered from to . A tree is a connected undirected graph without cycles. You have to assign integer weights to each edge of the tree, such that the resultant graph is a prime tree.
A prime tree is a tree where the weight of every path consisting of one or two edges is prime. A path should not visit any vertex twice. The weight of a path is the sum of edge weights on that path.
Consider the graph below. It is a prime tree as the weight of every path of two or less edges is prime. For example, the following path of two edges: has a weight of , which is prime. Similarly, the path of one edge: has a weight of , which is also prime.
Print any valid assignment of weights such that the resultant tree is a prime tree. If there is no such assignment, then print . It can be proven that if a valid assignment exists, one exists with weights between and as well.
Input Format: The input consists of multiple test cases. The first line contains an integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains one integer () — the number of vertices in the tree.
Then, lines follow. The -th line contains two integers and () denoting that edge number is between vertices and . It is guaranteed that the edges form a tree.
It is guaranteed that the sum of over all test cases does not exceed .
Output Format: For each test case, if a valid assignment exists, then print a single line containing integers (), where denotes the weight assigned to the edge numbered . Otherwise, print .
If there are multiple solutions, you may print any.
Note: For the first test case, there are only two paths having one edge each: and , both having a weight of , which is prime.
The second test case is described in the statement.
It can be proven that no such assignment exists for the third test case.