The first line contains one integer t () --- the number of test cases.
The first line of each test contains two positive integers n and m (,
) --- the number of vertices and edges in the given graph.
The following are m lines. Each of them contains two integers x and y, indicating there is an edge between vertex x and vertex y (, there are no duplicate edges in the same test)
The following line contains one integer q () -- the number of operations in this test. Then there is one more line contains q integers
(
).
The sum of n across the test cases doesn't exceed.
The sum of m across the test cases doesn't exceed.
And the sum of q across the test cases doesn't exceed.
For each test, output one line contains n integers --- the i-th integer of them representing the group that the vertex i-1 belongs to.
5 4 3 0 1 1 2 2 3 4 0 1 3 0 4 3 0 1 1 2 2 3 2 0 2 4 3 0 1 1 2 2 3 2 0 3 4 1 1 3 1 2 5 5 0 1 0 2 1 2 1 3 3 4 3 4 4 0
Take the first test for example:Initially, the four vertex is belong to 0, 1, 2, 3 respectively.After the first operation, the four vertex is belong to 0, 0, 2, 3 respectively.
After the second operation, because there is no vertex belong to 1 now. The four vertex is still belong to 0, 0, 2, 3 respectively.After the third operation, the four vertex is belong to 0, 0, 3, 3 respectively.
After the last operation, the four vertex is belong to 0, 0, 0, 0 respectively.