Bug colonies have been the center of attention of scientists for a long time. Through some technological advancements, we are now able to describe a bug colony using a number known as the degree of the colony. A colony of degree represents a male bug and one of degree represents a female bug. A colony of degree is obtained by merging a colony of degree together with a colony of degree . As such, the first few colonies are as follows:
- Colony : a male
- Colony : a female
- Colony : a male and a female
- Colony : a male and two females
You are the owner of the biggest bug farm in the world, having at your disposal a virtually infinite amount of colonies of any degree. Each day you receive offers, each described by two numbers and , meaning that you can sell as many colonies of type as you want and get money for each colony of that type.
Unfortunately, the antitrust laws on the bug trading market forbid you to sell more than bugs in a single day (selling a colony is equivalent to selling all the bugs in that colony).
Task
Given the description of days, if you optimally choose which offers to accept, what is the maximum amount of money you can obtain in each day?
Input data
The first line will contain the number of days .
The first line of each day contains the number of bugs and the most bugs you can sell that day . The next lines of each day contain the pair of numbers and .
Output data
You will print lines, the one containing the answer for the day.
Constraints and clarifications
- For tests worth 50 points: and .
Example
stdin
1
5 11
1 2
2 2
3 5
4 9
5 50
stdout
56
Explanation
It is optimal to choose the offer once and the one times.