Garbage truck is collecting garbage on its route starting at the dump and collecting garbage from pick up points in order (closest first). Garbage truck returns to the dump and empties its contents if it either
Given the weight limit that truck can carry and the list of pick up points with garbage weights, what is the distance that the truck will cover following the rules above?
Input starts with an integer T on the first line, the number of test cases.
Each case starts with the line with two integers W and N, the weight limit and the number of pick up points, respectively.
Then N lines follow, each containing integers x_i and w_i, the distance from the dump and the weight of the garbage at the pick up point respectively.
Constraints are as given: 1<=W<=1000, 1<=N<=1000, 0<x_i<=100,000, 1<=w_i<=W. Distances are distinct and given in order, i.e. for each i<j, x_i<x_j.
For each test case output an integer on a line - the distance covered by the garbage truck.
3 2 2 1 1 2 2 6 3 1 1 2 2 3 3 3 3 1 2 2 2 3 1
8 6 10