Your company was appointed to lay new asphalt on the highway of length $n$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.

Skipping the repair is necessary because of the climate. The climate in your region is periodical: there are $g$ days when the weather is good and if you lay new asphalt these days it becomes high-quality pavement; after that, the weather during the next $b$ days is bad, and if you lay new asphalt these days it becomes low-quality pavement; again $g$ good days, $b$ bad days and so on.

You can be sure that you start repairing at the start of a good season, in other words, days $1, 2, \dots, g$ are good.

You don't really care about the quality of the highway, you just want to make sure that at least half of the highway will have high-quality pavement. For example, if the $n = 5$ then at least $3$ units of the highway should have high quality; if $n = 4$ then at least $2$ units should have high quality.

What is the minimum number of days is needed to finish the repair of the whole highway?


-----Input-----

The first line contains a single integer $T$ ($1 \le T \le 10^4$) — the number of test cases.

Next $T$ lines contain test cases — one per line. Each line contains three integers $n$, $g$ and $b$ ($1 \le n, g, b \le 10^9$) — the length of the highway and the number of good and bad days respectively.


-----Output-----

Print $T$ integers — one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.


-----Example-----
Input
3
5 1 1
8 10 10
1000000 1 1000000

Output
5
8
499999500000



-----Note-----

In the first test case, you can just lay new asphalt each day, since days $1, 3, 5$ are good.

In the second test case, you can also lay new asphalt each day, since days $1$-$8$ are good.

Difficulty: interview

Starter code:

Solutions:
for i in range(int(input())):
    n,g,b=map(int,input().split())
    nn=(n+1)//2
    print(max(nn+(nn-1)//g*b,n))

for _ in range(int(input())):
    n, g, b = list(map(int, input().split()))
    half = (n - 1) // 2 + 1

    ans = (g + b) * (half // g) - b  # + (half % g)
    if half % g != 0:
        ans += b + half % g
    print(max(ans, n))


# import sys
#
# input = lambda: sys.stdin.readline().strip()
for i in range(int(input())):
    n,g, b = list(map(int, input().split()))
    n1 = n
    n = (n+1)//2
    k = n//g
    if n%g:
        print(max(n1,k*(g+b)+n%g))
    else:
        print(max(n1,g*k+b*(k-1)))


def iinput():
    return [int(x) for x in input().split()]


def main():
    n, g, b = iinput()
    z = (n + 1) // 2
    d = (z - 1) // g
    return max(d * b + z, n)


for i in range(int(input())):
    print(main())


import sys
input = sys.stdin.readline

t=int(input())
for tests in range(t):
    n,g,b=list(map(int,input().split()))
    ALL=(n+1)//2

    ANS=n

    week=-(-ALL//g)-1
    ANS=max(ANS,week*(g+b)+(ALL-week*g))

    print(ANS)


t = int(input())
for q in range(t):
    n, g, b = [int(i) for i in input().split()]
    num = n
    n = n // 2 + n % 2
    val = n // g
    d = 0
    if n % g == 0:
        d = (val - 1) * (b + g) + g
    else:
        d = val * (b + g) + n % g
    if d < num:
        print(num)
    else:
        print(d)
    


t = int(input())

def check(n, h, g, b, m):
    if m < n:
        return False
    loop, rest = divmod(m, g + b)
    ok = min(rest, g) + loop * g
    return ok >= h

for _ in range(t):
    n,g,b = list(map(int,input().split()))
    high = (n + 1) // 2
    ok, ng = 10 ** 20, 0
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if check(n, high, g, b, mid):
            ok = mid
        else:
            ng = mid
    print(ok)


def solve():
    n, g, b = [int(x) for x in input().split()]
    l = 0
    r = int(1e30)

    while r-l > 1:
        m = (l+r)//2

        blk = m // (g + b)
        cnt = blk * g + min(g, m % (g + b))

        if cnt >= (n+1)//2:
            r = m
        else:
            l = m
    
    print(max(r, n))

t = int(input())
for _ in range(t):
    solve()

import sys
import math
from collections import defaultdict
from collections import deque
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : list(map(int, input().split()))
go = lambda : 1/0
def write(*args, sep="\n"):
  for i in args:
    sys.stdout.write("{}{}".format(i, sep))
INF = float('inf')
MOD = int(1e9 + 7)
YES = "YES"
NO = "NO"

for _ in range(int(input())):
  try:
    n, g, b = read()

    total = math.ceil(n / 2)  

    s = 0
    e = 1 << 63
    while s <= e:
      m = (s + e) // 2
      good = 0
      bad = 0 

      x = m // (g + b)
      good += x * g
      bad += x * b 

      y = m - (m // (g + b)) * (g + b)
      good += min(y, g)
      bad += max(0, y - g)

      if good + bad >= n and good >= total:
        e = m - 1
      else:
        s = m + 1
    
    print(s)



    

  except ZeroDivisionError:
    continue

  except Exception as e:
    print(e)
    continue

for _ in range(int(input())):
	n,g,b = map(int,input().split())
	orign = n
	n = (n+1)//2
	com = ((n-1)//g)
	ans = com*(g+b)
	n -= com*g
	ans += n
	print(max(ans,orign))