A restaurant offers a menu of dishes, and you have decided to order exactly of them, all different. Dish on its own gives you units of enjoyment.
Some dishes taste better in a particular order, though. The chef has written down pairings: a pairing means that if you eat dish immediately after dish , with nothing in between, you gain another units on top. A pairing only counts in the direction it is written.
You may eat your dishes in any order you like. Find the largest total enjoyment you can reach.
Input
First line of input will be a single integer - the number of testcases.
The first line of each testcase contains three integers , and - the number of dishes on the menu, the number you will order, and the number of pairings.
The second line contains integers - the enjoyment each dish gives on its own.
Each of the next lines contains three integers , and - eating dish immediately after dish gives extra enjoyment.
Dishes are numbered to . No pairing is listed twice.
Output
For every testcase print a single line with the largest total enjoyment.
Example
2 2 2 1 1 1 2 1 1 4 3 2 1 2 3 4 2 1 5 3 4 2
3 12
In the first testcase eat dish and then dish : one unit from each dish, plus one more for the pairing. In the second, ordering dishes gives from the dishes themselves, and the pairing adds - the order scores the same .
Constraints
with , and
This problem is based on Kefa and Dishes, problem 580D from Codeforces Round 321, by Mike Mirzayanov and the Codeforces team. The statement here is our own.