#436. New Equipments II

New Equipments II

Description

Little Q's factory recently purchased nn pieces of new equipment, labeled by 1,2,,n1,2,\dots,n.

There are nn workers in the factory, labeled by 1,2,,n1,2,\dots,n. Each worker can be assigned to no more than one piece of equipment, and no piece of equipment can be assigned to multiple workers. If Little Q assigns the ii-th worker to the jj-th piece of equipment, they will bring ai+bja_i+b_j profits. However, these workers are not so experienced, there are mm extra constraints. In each constraint, you will be given two integers uiu_i and viv_i, denoting the uiu_i-th worker can't be assigned to the viv_i-th piece of equipment.

Now please for every kk (1kn1\leq k\leq n) find kk pairs of workers and pieces of equipment, then assign workers to these pieces of equipment, such that the total profits for these kk pairs are maximized, or determine it is impossible.

Format

Input

The first line contains a single integer TT (1T2001 \leq T \leq 200), the number of test cases. For each test case:

The first line contains two integers nn and mm (1n40001 \leq n \leq 4\,000, 1m100001\leq m\leq 10\,000), denoting the number of workers/pieces of new equipment and the number of constraints.

The second line contains nn integers a1,a2,,ana_1,a_2,\dots,a_n (1ai1091\leq a_i\leq 10^9).

The third line contains nn integers b1,b2,,bnb_1,b_2,\dots,b_n (1bi1091\leq b_i\leq 10^9).

Each of the following mm lines contains two integers uiu_i and viv_i (1ui,vin1\leq u_i,v_i\leq n), denoting the uiu_i-th worker can't be assigned to the viv_i-th piece of equipment. Each pair of uiu_i and viv_i will be described at most once.

It is guaranteed that there will be at most 1010 test cases such that n>100n>100.

Output

For each test case, output nn lines, the kk-th (1kn1\leq k\leq n) of which containing an integer, denoting the maximum possible total profits for kk pairs of workers and pieces of equipment. Note that if it is impossible to find such kk pairs, print ''-1\texttt{-1}'' at this line.

Samples

2
4 4
10 20 30 40
5 10 7 8
4 2
3 2
1 4
1 2
2 2
1 1
1 1
1 1
1 2
48
85
115
130
2
-1