#P468. 【例85.1】 金银岛

【例85.1】 金银岛

Description

On Treasure Island, there are ss types of metals, each with different weights (n1n_1, n2n_2, ..., nsn_s) and different values (v1v_1, v2v_2, ..., vsv_s). The total weight of metals that can be carried at once cannot exceed ww. What is the maximum value of metals that can be carried?
Note: Metals can be divided into any fraction, and the value of a metal is proportional to its weight.

Input Format

The first line contains the number of test cases kk, followed by kk groups of input.
Each test case consists of 3 lines: Line 1 contains a positive integer ww (1<w100001 < w ≤ 10000), representing the maximum weight capacity. Line 2 contains a positive integer ss (1<s<1001 < s < 100), representing the number of metal types. Line 3 contains 2s2s positive integers: n1n_1, v1v_1, n2n_2, v2v_2, ..., nsn_s, vsv_s, representing the total weight and total value of the first, second, ..., ss-th type of metal (1ni100001 ≤ n_i ≤ 10000, 1vi100001 ≤ v_i ≤ 10000).

Output Format

kk lines, each containing the result for one test case. The output should be accurate to 2 decimal places.

Sample

2
50
4
10 100 50 30 7 34 87 100
10000
5
1 43 43 323 35 45 43 54 87 43
171.93
508.00