#Lutece0120. Find the Treasure

Find the Treasure

Migrated from Lutece 120 Find the Treasure

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Under the guide of CC, flower fairies have successfully passed through the weird world and they left MM considerable treasures in it.

Hongshu, an excellent treasure hunter, unexpectedly obtained the treasure map of the world which describes each treasure in detail. The ithi_{th} treasure contains a wealth of BiB_i. To obtain the ithi_{th} treasure, Hongshu have to collect KiK_i different keys to unlock the treasure box. However, keys needed are very special and collect the ithi_{th} key cost him AiA_i. A key can be used more than once. Now Hongshu is wondering how to make his strategy in order to make his profit maximized.

Input

The first line of the input is TT (no more than 100100), which stands for the number of test cases you need to solve.

Each test case begins with NN, MM representing the number of keys and treasures. NN and MM are integers no more than 100100. The next line contains NN integers, the ithi_{th} integer AiA_i (Ai100000A_i \leq 100000) represents the cost to collect the ithi_{th} key. Then follows a line contains MM integers, the ithi_{th} integer BiB_i (Bi100000B_i \leq 100000) represents the wealth of the ithi_{th} treasure. Then MM lines followed. Each describes a treasure. Each line begins with an integer KK (KNK \leq N), which is the number of different keys you need to unlock the treasure box. Then K integers followed represents the index of each key (index numbered from 11).

Output

For each case, print the maximum profit in the first line. Then print the number of keys to collect and the indices of them in ascending order separated by space in the second line. It is guaranteed that the answer is unique.

Samples

1
4 4
7 4 2 7
7 9 0 0
1 2
1 4
1 3
1 1
5
2 2 4

Resources

The 8th UESTC Programming Contest Final