Class Attendance

4

1 votes
Easy-Medium
Problem

On a particular day combine class for the both sections A and B is going on . So after a long lecture of 1 hour when the class finished the teacher decided to take the attendance of the class. Today N students are present in the class having roll number from 1 to N .
As the teacher usually teaches Section B has been habituated of calling out even roll calls. So he takes the attendance of section B first (that is students having even roll numbers ) after that, he take attendance of sectin A (students having odd roll numbers ). It takes 1 minute by the teacher for calling one roll call and also after every X roll calls he takes the break of 2 minutes .
A student having roll number Y is waiting for his turn . Can you help him out in telling, after how many minutes he will complete his attendance.

Input:
First line of input contains T - Total no. of test cases
Each test case has three space separated integers N, X and Y denoting total number of students that are present, X and Y as mentioned above.

Output:
For each testcase, print after how many minutes he will complete his attendance.

Constraints
1<=T<=105
1<=X,Y<=N<=1018

Sample Input
3
10 2 2
6 2 1
4 1 3
Sample Output
1
6
10
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In the first case,
The student having roll number 2 , his attendance will be taken first so in 1 minute.
The attendance will be taken in the following manner
roll number 2, it will take 1 min
roll number 4, it will take 1 min
after that teacher will take 2 minute rest
then of roll number 6, it will take 1 minute
after that roll number 1 it will take another 1 minute.
So total time taken will be 6 minutes.

Editor Image

?