Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

Chef is a very lazy person. Whatever work is supposed to be finished in x units of time, he finishes it in m * x units of time. But there is always a limit to laziness, so he delays the work by at max d units of time. Given x, m, d, find the maximum time taken by Chef to complete the work.

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

- First line will contain T, number of testcases. Then the testcases follow. 
- Each testcase contains a single line of input, three integers x, m, d. 

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

For each testcase, output in a single line answer to the problem.

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

$1 ≤ T ≤ 10^{4}$
$1 ≤ x, m ≤ 10$
$0 ≤ d < 100$

----- Sample Input 1 ------ 
3

1 1 0

1 3 1

2 2 3
----- Sample Output 1 ------ 
1

2

4
----- explanation 1 ------ 
TestCase $1$: Chef takes $1 * 1 = 1$ unit of time which is equal to the upper bound($1 + 0 = 1$ unit) to do the work.   

TestCase $2$: Chef takes $min(1 * 3, 1 + 1) = min(3, 2) = 2$ units of time to do the work.   

TestCase $3$: Chef takes $2 * 2 = 4$ units of time which is less than the upper bound($2 + 3 = 5$ units) to do the work.

Difficulty: EASY
Tags: Ad-hoc

Starter code:

Solutions:
def chef():
	(x, y, z) = map(int, input().split())
	if x * y < x + z:
		return x * y
	else:
		return x + z
for _ in range(int(input())):
	print(chef())


for i in range(int(input())):
	x = list(map(int, input().split()))
	s = x[0] * x[1]
	p = x[0] + x[2]
	print(min(s, p))


num = int(input())
for i in range(num):
	(n1, n2, n3) = input().split(' ')
	n1 = int(n1)
	n2 = int(n2)
	n3 = int(n3)
	mul = n1 * n2
	add = n1 + n3
	print(min(mul, add))


for i in range(int(input())):
	(x, m, d) = map(int, input().split())
	a = m * x
	b = d + x
	print(min(a, b))


tc = int(input())
for i in range(tc):
	(x, m, z) = map(int, input().split())
	print(min(x * m, x + z))


for i in range(int(input())):
	x = list(map(int, input().split()))
	a = x[0] * x[1]
	b = x[0] + x[2]
	c = min(a, b)
	print(c)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	print(min(a * b, a + c))


T = int(input())
for i in range(0, T):
	(x, m, d) = map(int, input().split())
	print(min(x + d, x * m))


for i in range(int(input())):
	(x, m, d) = map(int, input().split())
	time = [m * x, x + d]
	max_time = min(time)
	print(max_time)


for _ in range(int(input())):
	(x, m, d) = map(int, input().split())
	print(min(x * m, x + d))


t = int(input())
for i in range(t):
	(x, m, d) = tuple(map(int, input().split()))
	print(min(x * m, x + d))


n = int(input())
for n in range(0, n):
	(x, m, d) = map(int, input().split())
	print(min(x * m, x + d))


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	print(min(a * b, a + c))


for i in range(int(input())):
	(x, m, d) = map(int, input().split())
	if m * x < x + d:
		print(m * x)
	else:
		print(x + d)


t = int(input())
for i in range(t):
	(x, m, d) = map(int, input().split())
	A = x * m
	B = x + d
	print(min(A, B))


n = int(input())
for i in range(n):
	(a, b, c) = tuple(map(int, input().split()))
	print(min(a * b, a + c))


T = int(input())
while T > 0:
	(x, m, d) = input().split()
	if int(x) * int(m) > int(x) + int(d):
		print(int(x) + int(d))
	else:
		print(int(x) * int(m))
	T = T - 1


n = int(input())
for i in range(n):
	lst = list(map(int, input().split()))[:3]
	if lst[0] * lst[1] <= lst[0] + lst[2]:
		print(lst[0] * lst[1])
	else:
		print(lst[0] + lst[2])


t = int(input())
for i in range(t):
	(SX, M, D) = map(int, input().split())
	Finish = SX * M
	maxTime = SX + D
	if Finish == maxTime:
		print(maxTime)
	elif Finish > maxTime:
		print(maxTime)
	else:
		print(Finish)


N = int(input())
for i in range(N):
	(x, y, z) = map(int, input().split())
	a = x * y
	b = x + z
	c = min(a, b)
	print(c)


t = int(input())
for i in range(t):
	A = list(map(int, input().split()))
	a = A[0] * A[1]
	b = A[0] + A[2]
	if a == b:
		print(a)
	else:
		print(min(a, b))


t = int(input())
for i in range(t):
	min = 1
	(x, m, d) = map(int, input().split())
	q = x * m
	w = x + d
	if q > w:
		min = w
	else:
		min = q
	print(min)


test = int(input())
for i in range(test):
	(x, m, d) = map(int, input().split())
	print(min(x * m, x + d))


t = int(input())
for i in range(t):
	(x, m, d) = map(int, input().split())
	tt = m * x
	tt1 = x + d
	ftt = min(tt, tt1)
	print(ftt)


import math
n = int(input())
for i in range(n):
	(x, y, z) = map(int, input().split())
	print(min(x * y, x + z))


t = int(input())
for _ in range(t):
	(x, m, d) = map(int, input().split())
	a1 = x * m
	a2 = x + d
	print(min(a1, a2))


t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split())
	print(min(x * y, x + z))


for _ in range(int(input())):
	(x, m, d) = [int(x) for x in input().split()]
	work1 = x * m
	work2 = x + d
	res = min(work1, work2)
	print(res)


for t in range(int(input())):
	(x, m, d) = map(int, input().split())
	fn = m * x
	ma = x + d
	print(min(fn, ma))


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	r1 = a * b
	r2 = a + c
	if r1 < r2:
		print(r1)
	else:
		print(r2)


for i in range(int(input())):
	(x, y, d) = map(int, input().split())
	a = x * y
	b = x + d
	if a <= b:
		print(a)
	elif a == b:
		print(a)
	else:
		print(b)


for i in range(int(input())):
	(m, n, x) = map(int, input().split())
	print(min(m * n, m + x))


for i in range(int(input())):
	(x, m, d) = list(map(int, input().split()))
	c = x * m
	e = x + d
	print(min(e, c))


T = int(input())
for i in range(T):
	(X, Y, Z) = map(int, input().split())
	A = X * Y
	B = X + Z
	if A < B:
		print(A)
	else:
		print(B)