#t370. 金银岛

金银岛

Treasure Island

Background

Special for beginners, ^_^

Problem Description

One day KID flew a flying machine to a gold-and-silver island where many precious metals lay. Although KID prefers artworks made of gems, he does not refuse such precious metals. However, he only brought one bag, and the bag can hold items of total weight at most ww.

There are ss kinds of metals on the island. The metals of different kinds have different weights, namely n1,n2,…,nsn_1, n_2, \dots, n_s, and the total value of each kind is also different, namely v1,v2,…,vsv_1, v_2, \dots, v_s. KID wants to take away as much value of metals as possible in one trip. What is the maximum total value he can take?

Note that the metals can be divided arbitrarily, and the value of a metal is proportional to its weight.

Input Format

The first line is the number of test cases kk, followed by kk groups of input.

Each test case occupies 33 lines.

The first line is a positive integer ww (1≤w≤100001 \le w \le 10000), the weight limit of the bag.

The second line is a positive integer ss (1≤s≤1001 \le s \le 100), the number of kinds of metal.

The third line contains 2s2s positive integers, namely n1,v1,n2,v2,…,ns,vsn_1, v_1, n_2, v_2, \dots, n_s, v_s, which are the total weight and total value of the first, second, ..., ss-th kind of metal (1≤ni≤100001 \le n_i \le 10000, 1≤vi≤100001 \le v_i \le 10000).

Output Format

Output kk lines, each line corresponding to one input. The output should be accurate to 22 decimal places.

Sample Input 1

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

Sample Output 1

171.93
508.00

Constraints

1s, 1024KiB for each test case.