#CF2230A. A. Optimal Purchase
A. Optimal Purchase
A. Optimal Purchase
You have a group of students who need access to an online course. Two types of access keys are available in the store:
- Individual key: costs dollars and gives access to one student.
- Group key: costs dollars and gives access to a group of up to three students inclusive. A group key can also be used for fewer students (one or two), and its price does not change.
Your task is to determine the minimum amount of money needed to provide access to the online course for all students.
The first line contains one integer () — the number of test cases.
Each test case consists of one line containing three integers () — the number of students, the cost of an individual key, and the cost of a group key.
For each test case, output one integer — the minimum amount of money needed to provide access to the online course for all students.
ExampleNoteIn the first example, you can buy group key and individual keys.
In the second example, you can buy individual keys.
In the third example, you can buy group key.
In the fourth example, you can buy individual key.
Input
InputThe first line contains one integer () — the number of test cases.
Each test case consists of one line containing three integers () — the number of students, the cost of an individual key, and the cost of a group key.
Output
OutputFor each test case, output one integer — the minimum amount of money needed to provide access to the online course for all students.
Samples
5
5 10 25
4 10 50
1 20 15
2 10 1
3 1 1
45
40
15
1
1
Note
NoteIn the first example, you can buy group key and individual keys.
In the second example, you can buy individual keys.
In the third example, you can buy group key.
In the fourth example, you can buy individual key.