Chef is playing a videogame, and is getting close to the end. He decides to finish the rest of the game in a single session.

There are X levels remaining in the game, and each level takes Chef Y minutes to complete. To protect against eye strain, Chef also decides that every time he completes 3 levels, he will take a Z minute break from playing. Note that there is no need to take this break if the game has been completed.

How much time (in minutes) will it take Chef to complete the game?

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- The first and only line of input will contain three space-separated integers X, Y, and Z.

------ Output Format ------ 

For each test case, output on a new line the answer — the length of Chef's gaming session.

------ Constraints ------ 

$1 ≤ T ≤ 100$
$1 ≤ X ≤ 100$
$5 ≤ Y ≤ 100$
$5 ≤ Z ≤ 15$

----- Sample Input 1 ------ 
4
2 12 10
3 12 10
7 20 8
24 45 15

----- Sample Output 1 ------ 
24
36
156
1185

Difficulty: EASY

Solutions:
t = int(input())
for tc in range(t):
	(x, y, z) = map(int, input().split(' '))
	if x <= 3:
		m = x * y
		print(m)
	elif x % 3 == 0:
		k = z * (x // 3 - 1)
		m = k + x * y
		print(m)
	else:
		k = x // 3 * z
		m = k + x * y
		print(m)


t = int(input())
for _ in range(t):
	(x, y, z) = map(int, input().split())
	if x % 3 == 0:
		print(x * y + (x // 3 - 1) * z)
	else:
		print(x * y + x // 3 * z)


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a < 3:
		print(a * b)
	elif a % 3 == 0:
		print((a // 3 - 1) * c + a * b)
	else:
		print(a // 3 * c + a * b)


t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split())
	a = x * y
	b = x // 3
	if x > 3:
		if x % 3 == 0:
			b = b - 1
		print(a + b * z)
	else:
		print(a)


for i in range(int(input())):
	(x, y, z) = map(int, input().split())
	n = x // 3
	if x <= 3:
		print(x * y)
	elif x > 3 and x % 3 != 0:
		print(x * y + n * z)
	elif x > 3 and x % 3 == 0:
		print(x * y + (n - 1) * z)


N = int(input())
for i in range(N):
	(X, Y, Z) = map(int, input().split())
	if X <= 3:
		print(X * Y)
	else:
		if X % 3 == 0:
			n = X / 3 - 1
		else:
			n = int(X / 3)
		total = X * Y + Z * n
		print(int(total))


t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split())
	if x <= 3:
		print(y * x)
	elif x % 3 != 0:
		s = x // 3
		sum = y * x + s * z
		print(sum)
	elif x % 3 == 0:
		s = x // 3
		s = s - 1
		sum = y * x + s * z
		print(sum)


for i in range(int(input())):
	(x, y, z) = map(int, input().split())
	time = 0
	count = 0
	while x:
		if count == 3:
			time = time + z
			count = 0
		time = time + y
		x = x - 1
		count += 1
	print(time)


def calculate_time(l):
	levels = l[0]
	complete_time = l[1]
	break_time = l[2]
	res = 0
	if levels <= 3:
		return levels * complete_time
	else:
		while levels > 3:
			res += 3 * complete_time + break_time
			levels -= 3
		if levels <= 3:
			res += levels * complete_time
	return res
n = int(input())
for i in range(n):
	l = list(map(int, input().split()))
	print(calculate_time(l))


t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split())
	if x <= 3:
		print(x * y)
	elif x % 3 == 0:
		r = int(x / 3) - 1
		print(x * y + r * z)
	else:
		r = int(x / 3) - 1
		print(x * y + r * z + z)


for _ in range(int(input())):
	(X, Y, Z) = map(int, input().split())
	if X % 3 != 0:
		print(X * Y + X // 3 * Z)
	else:
		print(X * Y + X // 3 * Z - Z)


t = int(input())
for i in range(0, t):
	level = list(map(int, input().split()))
	if level[0] % 3 == 0:
		breaks = level[0] // 3 - 1
	else:
		breaks = level[0] // 3
	z = breaks * level[2]
	print(level[0] * level[1] + z)


t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split())
	m = x * y
	n = x // 3
	if x % 3 == 0:
		n -= 1
		print(m + n * z)
	else:
		print(m + n * z)


t = int(input())
while t > 0:
	[x, y, z] = map(int, input().split())
	if x == 0:
		print(0)
	elif x % 3 == 0:
		print(x * y + (x // 3 - 1) * z)
	else:
		print(x * y + x // 3 * z)
	t -= 1


for _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	r = 0
	for i in range(1, x + 1):
		r += y
		if i % 3 == 0 and i != x:
			r += z
	print(r)


T = int(input())
for i in range(T):
	(X, Y, Z) = map(int, input().split())
	x = X // 3
	if X <= 3:
		print(X * Y)
	elif X % 3 != 0:
		print(X * Y + x * Z)
	else:
		print(X * Y + x * Z - Z)


t = int(input())
for i in range(t):
	(X, Y, Z) = map(int, input().split())
	count = 0
	if X <= 3:
		print(Y * X)
	elif X % 3 == 0:
		print(Y * X + (X // 3 - 1) * Z)
	else:
		print(Y * X + X // 3 * Z)


for i in range(int(input())):
	(x, y, z) = map(int, input().split())
	if x > 3:
		print(int(x * y + x // 3 * z - z)) if x % 3 == 0 else print(int(x * y + x // 3 * z))
	else:
		print(x * y)


t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split())
	d = (x - 1) // 3
	if x <= 3:
		print(x * y)
	else:
		print(x * y + d * z)


import math
for i in range(int(input())):
	(x, y, z) = map(int, input().split())
	if x <= 3:
		print(x * y)
	else:
		print(x * y + (math.ceil(x / 3) - 1) * z)


def gaming(t):
	for _ in range(t):
		(x, y, z) = map(int, input().split())
		if x > 3:
			total_time = x * y
			break_time = x // 3
			if x % 3 == 0:
				print(total_time + (break_time - 1) * z)
			else:
				print(total_time + break_time * z)
		else:
			print(x * y)
gaming(int(input()))


n = int(input())
for i in range(n):
	a = list(map(int, input().split(' ')))
	t = 0
	while a[0] > 3:
		a[0] -= 3
		t += a[1] * 3
		t += a[2]
	t += a[1] * a[0]
	print(t)


T = int(input())
for i in range(T):
	TimeTaken = 0
	a = 0
	(x, y, z) = map(int, input().split())
	for j in range(x):
		TimeTaken = TimeTaken + y
		if j > 0 and j % 3 == 0:
			TimeTaken = TimeTaken + z
	print(TimeTaken)


t = int(input())

def rest(x, z):
	if x <= 3:
		return 0
	if x % 3:
		return x // 3 * z
	return (x // 3 - 1) * z
for _ in range(t):
	(x, y, z) = map(int, input().split(' '))
	rested = rest(x, z)
	time_played = x * y + rested
	print(time_played)


T = int(input())
for _ in range(T):
	(X, Y, Z) = map(int, input().split())
	total_time = X * Y + (X - 1) // 3 * Z
	print(total_time)


t = int(input())
for _ in range(t):
	(levels_remain, minutes_per_level, break_time) = map(int, input().split())
	breaks_needed = levels_remain // 3
	if levels_remain % 3 == 0:
		breaks_needed -= 1
	print(levels_remain * minutes_per_level + break_time * breaks_needed)


t = int(input())
for i in range(t):
	(x, y, z) = list(map(int, input().split()))
	if x <= 3:
		c = x * y
		print(c)
	elif x % 3 != 0:
		c = x * y + int(x / 3) * z
		print(c)
	elif x % 3 == 0 and x != 3:
		c = x * y + (int(x / 3) - 1) * z
		print(c)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	t = 0
	cnt = 0
	while a:
		if cnt == 3:
			t = t + c
			cnt = 0
		t = t + b
		a = a - 1
		cnt += 1
	print(t)


T = int(input())
for i in range(T):
	(x, y, z) = map(int, input().split())
	k = x * y
	l = x // 3
	if x % 3 == 0:
		l -= 1
		print(k + l * z)
	else:
		print(k + l * z)


T = int(input())
while T > 0:
	(X, Y, Z) = map(int, input().split())
	if X % 3 == 0:
		print((X // 3 - 1) * Z + X * Y)
	else:
		print(X // 3 * Z + X * Y)
	T = T - 1


t = int(input())
for i in range(t):
	(r, c, b) = map(int, input().split())
	tt = r * c
	x = r // 3
	if r <= 3:
		print(tt)
	elif r % 3 == 0:
		print(tt + (x - 1) * b)
	else:
		print(tt + x * b)


t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split())
	d = (x - 1) // 3
	m = x * y
	print(m + z * d)


T = int(input())
for i in range(T):
	(X, Y, Z) = map(int, input().split())
	M = X * Y
	if X > 3:
		if X % 3 == 0:
			S = M + Z * (X // 3 - 1)
			print(S)
		else:
			S = M + Z * (X // 3)
			print(S)
	else:
		print(M)


t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split())
	time = x * y
	brk = x // 3
	if x % 3 == 0:
		brk -= 1
		print(time + brk * z)
	else:
		print(time + brk * z)