Dividing the Loot

No attempts yetTime limit1sMemory limit128 MB

Problem

You have successfully led a band of pirates in capturing a merchant ship. You have seized gold coins, silver coins, and other valuables, and now it is time to divide the loot. To avoid a mutiny, it is important to keep everyone satisfied. A pirate becomes unhappy if any other pirate receives more items than he does. Because of this, you may have to settle for fewer items than the others, or even throw some items into the open sea. Fortunately, the other pirates have no notion of the items' values, but you do. Can you get the most out of this for yourself without provoking a mutiny?

Input

The first line of the input contains a single integer: the number of test cases that follow. Each test case has the following format:

  • One line with two integers $P$ and $N$ ($0 \le P \le 1000$, $1 \le N \le 1000$): the number of other pirates you must share the loot with, and the number of items, respectively.
  • One line with $N$ integers $v_i$ ($1 \le v_i \le 1000$): the value of each item.

Output

For each test case, print a single integer on its own line: the maximum total value of the items you can keep for yourself while keeping all the other pirates satisfied.