Jem is famous for his laziness at school. He always leaves things to last minute. Now Jem has N problems in the assignment of "Advanced topics in algorithm" class to solved. The assignment is due tomorrow and as you may guess he hasn't touch any of the problems. Fortunately he got a plan as always.

The first step will be buying a pack of Red Bull and then to work as hard as he can. Here is how he is going to spend the remaining time:

Jem will not take a break until he finishes at least half of the remaining problems. Formally, if N is even then he will take he first break after finishing N / 2 problems. If N is odd then the break will be after he done (N + 1) / 2 problems. Each of his break will last for B minutes. Initially, he takes M minutes in solving a problem, after each break he will take twice more time in solving a problem, i.e. 2 * M minutes per problem after the first break.

Jem will start working soon and ask you to help him calculate how much time it will take until he finish the last problem!

-----Input-----

The first line contains a single integer T represents the number of test cases in the input.
Each line in the next T line contains three integers N, B and M represents a test case.

-----Output-----

For each test case output a single line containing an integer represent how much time Jem will need (in minutes).

-----Constraints-----
- 1 ≤ T ≤ 100
- 1 ≤ N, B, M ≤ 108

-----Example-----
Input:
2
9 1 2
123456 123456 123456

Output:
45
131351258112

-----Explanation-----

In the first test case, Jem will proceed as below:

- Initially, Jem has 9 problems to solve. since it is an odd number, Jem will finish the first (9 + 1) / 2 = 5 problems with speed of 2 minutes/problem.
- After that, Jem takes 1 minute break.
- Now he has 4 problems to solve, which is an even number, so Jem will solve the next 4 / 2 = 2 problems. his speed after the first break has now became 4 minutes/problem.

- Again, he takes a 1 minute break.
- he has now 2 problems left so he do one more problem in 8 minutes.
- He takes 1 minute break.
- he solves the last problem in 16 minutes.

So, Jem will need time = 5 × 2 + 1 + 2 × 4 + 1 + 8 + 1 + 16  = 45

Source: codechef | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
for t in range(int(input())):
	(n, b, m) = list(map(int, input().split()))
	ans = 0
	while n > 0:
		ans += b
		half = (n + 1) / 2 if n % 2 else n / 2
		ans += m * half
		m *= 2
		n = n - half
	print(ans - b)


t = int(input())
while t > 0:
	t = t - 1
	T = 0
	(N, B, M) = list(map(int, input().split()))
	while N != 0:
		T = T + int((N + 1) / 2) * M + B
		M = 2 * M
		N = int(N / 2)
	print(T - B)


def e_o(t):
	if t % 2 == 0:
		return 1
	else:
		return 0

def check(t):
	n = t[0]
	b = t[1]
	m = t[2]
	s = 0
	while n > 0:
		if e_o(n) == 1:
			time = n / 2 * m
			m = 2 * m
			s = s + time + b
			n = n - n / 2
		else:
			time = (n + 1) / 2 * m
			m = 2 * m
			s = s + time + b
			n = n - (n + 1) / 2
	print(s - b)
T = eval(input())
for i in range(0, T):
	t = list(map(int, input().strip().split()))
	check(t)


import sys
for i in range(int(input())):
	[N, B, M] = list(map(int, input().split()))
	t = 0
	while N > 0:
		if N % 2 == 0:
			t += N / 2 * M
			N = N / 2
		else:
			t += (N + 1) / 2 * M
			N = (N - 1) / 2
		M = M * 2
		if N > 0:
			t += B
	print(t)


def total_time(n, b, m):
	t = 0
	while n != 1:
		if n % 2 == 0:
			x = n / 2
		else:
			x = (n + 1) / 2
		t += m * x
		m *= 2
		t += b
		n -= x
	t += m
	return t
T = int(input())
for i in range(T):
	(N, B, M) = [int(z) for z in input().split()]
	print(total_time(N, B, M))


t = eval(input(''))
for i in range(0, t):
	num = list(map(int, input().split()))
	n = num[0]
	b = num[1]
	m = num[2]
	h = 0
	tt = 0
	f = 0
	while n > 1:
		h += 1
		if n % 2 == 0:
			f = n / 2
		else:
			f = (n + 1) / 2
		if h > 1:
			m = 2 * m
		tt = tt + f * m + b
		n = n - f
	if n == 1:
		if h > 1:
			tt = tt + 2 * n * m
		else:
			tt = tt + n * m
	print(tt)


def __starting_point():
	t = input()
	t = int(t)
	while t > 0:
		string = input()
		ip_list = string.split(' ')
		n = int(ip_list[0])
		b = int(ip_list[1])
		m = int(ip_list[2])
		ans = 0
		while n > 0:
			if n % 2 == 0:
				ans += n / 2 * m
				n -= n / 2
				if n > 0:
					ans += b
			else:
				ans += (n + 1) / 2 * m
				n = (n - 1) / 2
				if n > 0:
					ans += b
			m *= 2
		print(ans)
		t -= 1
__starting_point()


t = eval(input())
while t:
	t -= 1
	(n, b, m) = list(map(int, input().split()))
	minute = 0
	while n > 0:
		if n % 2 == 0:
			n = n / 2
			minute += n * m
		else:
			n = (n - 1) / 2
			minute += (n + 1) * m
		minute += b
		m *= 2
	print(minute - b)


def calc(n, b, m):
	if n == 1:
		return m
	if n % 2 == 0:
		return m * n / 2 + b + calc(n / 2, b, m * 2)
	else:
		return m * (n + 1) / 2 + b + calc((n - 1) / 2, b, m * 2)
t = int(input())
while t != 0:
	t = t - 1
	(n, b, m) = list(map(int, input().split()))
	print(calc(n, b, m))


t = int(input())
while t > 0:
	ans = 0
	t -= 1
	s = input()
	(n, b, m) = s.split()
	n = int(n)
	b = int(b)
	m = int(m)
	n1 = n
	while n > 0:
		if n % 2 == 0:
			half = n / 2
		else:
			half = (n + 1) / 2
		ans += half * m
		n -= half
		m *= 2
		if n > 0:
			ans += b
	print(ans)


import sys

def lazy_jem(N_B_M):
	time_taken = 0
	while N_B_M[0] != 1:
		if N_B_M[0] % 2 == 0:
			time_taken += N_B_M[0] / 2 * N_B_M[2]
			N_B_M[0] = N_B_M[0] - N_B_M[0] / 2
		else:
			time_taken += (N_B_M[0] + 1) / 2 * N_B_M[2]
			N_B_M[0] = N_B_M[0] - (N_B_M[0] + 1) / 2
		N_B_M[2] = 2 * N_B_M[2]
		time_taken += N_B_M[1]
	time_taken += N_B_M[2]
	print(time_taken)
test_cases = eval(input())
for i in range(test_cases):
	N_B_M = list(map(int, input().strip().split(' ')))
	lazy_jem(N_B_M)


def __starting_point():
	tests = int(input())
	for _ in range(tests):
		(n, b, m) = list(map(int, input().split()))
		ans = 0
		itr = 1
		k = n
		k1 = n
		while k >= 1:
			if k % 2 == 0:
				k = k // 2
			else:
				k = (k + 1) // 2
			ans += k * (itr * m)
			k = k1 - k
			k1 = k
			ans += b
			itr *= 2
		print(ans - b)
__starting_point()


t = eval(input())
while t > 0:
	t = t - 1
	(n, b, m) = list(map(int, input().split()))
	s = n / 2
	p = 0
	if n % 2 == 0:
		p = n / 2
	else:
		p = (n + 1) / 2
	ans = 0
	i = 0
	n = n - p
	while n > 0:
		ans = ans + p * m + b
		m = m * 2
		if n % 2 == 0:
			p = n / 2
		else:
			p = (n + 1) / 2
		n = n - p
		i = i + 1
	ans = ans + m
	print(ans)