A new TV streaming service was recently started in Chefland called the Chef-TV.

A group of N friends in Chefland want to buy Chef-TV subscriptions. We know that 6 people can share one Chef-TV subscription. Also, the cost of one Chef-TV subscription is X rupees. 
Determine the minimum total cost that the group of N friends will incur so that everyone in the group is able to use Chef-TV.

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

- The first line contains a single integer T — the number of test cases. Then the test cases follow.
- The first and only line of each test case contains two integers N and X — the size of the group of friends and the cost of one subscription.

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

For each test case, output the minimum total cost that the group will incur so that everyone in the group is able to use Chef-TV.

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

$1 ≤ T ≤ 1000$
$1 ≤ N ≤ 100$
$1 ≤X ≤1000$

----- Sample Input 1 ------ 
3
1 100
12 250
16 135

----- Sample Output 1 ------ 
100
500
405

----- explanation 1 ------ 
- Test case 1: There is only one person in the group. Therefore he will have to buy $1$ subscription. Therefore the total cost incurred is $100$.
- Test case 2: There are $12$ people in the group. Therefore they will have to buy $2$ subscriptions. Therefore the total cost incurred is $500$.
- Test case 3: There are $16$ people in the group. Therefore they will have to buy $3$ subscriptions. Therefore the total cost incurred is $405$.

Source: codechef | Difficulty: EASY
Tags: Mathematics

Implementation


Solutions:
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	if a % 6 == 0:
		print(a // 6 * b)
	else:
		print((a // 6 + 1) * b)


for i in range(int(input())):
	(N, X) = map(int, input().split())
	if N % 6 == 0:
		print(N // 6 * X)
	else:
		print((N // 6 + 1) * X)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n <= 6:
		print(x)
	elif n % 6 == 0:
		print(n // 6 * x)
	else:
		print((n // 6 + 1) * x)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if n == 1:
		print(x)
	else:
		p = n % 6
		if p == 0:
			print(int(n / 6) * x)
		else:
			print(int(n / 6 + 1) * x)


import math
t = int(input())
for i in range(t):
	(n, x) = [int(x) for x in input().split()]
	print(math.ceil(n / 6) * x)


s = int(input())
for a in range(s):
	(n, x) = map(int, input().split())
	if n % 6 == 0:
		g = int(n / 6)
	else:
		g = int(n / 6 + 1)
	print(g * x)


import math
a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	l = math.ceil(x / 6)
	print(l * y)


T = int(input())
for i in range(T):
	(a, b) = map(int, input().split())
	if a % 6 == 0:
		print(a // 6 * b)
	elif a % 6 != 0:
		print((a // 6 + 1) * b)
	else:
		print(b)


import math
for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	print(math.ceil(n / 6) * x)


import math
for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = math.ceil(a / 6)
	print(c * b)


import math
T = int(input())
for i in range(T):
	(N, X) = map(int, input().split())
	if N <= 6:
		print(X)
	elif N % 6 == 0:
		print(N // 6 * X)
	else:
		print((N // 6 + 1) * X)


a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	if x % 6 == 0:
		print(int(x / 6 * y))
	else:
		print((x // 6 + 1) * y)


t = int(input())
while t:
	(n, x) = map(int, input().split())
	print(n // 6 * x if n >= 6 and n % 6 == 0 else (n // 6 + 1) * x if n >= 6 and n % 6 != 0 else x)
	t -= 1


def cost(n, x):
	r = n // 6
	s = n % 6
	if s != 0:
		r = r + 1
	return r * x
t = int(input())
for i in range(1, t + 1):
	(n, x) = map(int, input().split())
	res = cost(n, x)
	print(res)


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	if a < 6:
		print(b)
	elif a % 6 == 0:
		print(a // 6 * b)
	else:
		print((a // 6 + 1) * b)


x = int(input())
for i in range(x):
	(a, b) = map(int, input().split())
	c = -(a // -6) * b
	print(c)


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


import math
T = int(input())
for i in range(T):
	(X, Y) = map(int, input().split())
	Z = math.ceil(X / 6)
	if X == 1:
		print(X * Y)
	else:
		print(Z * Y)


T = int(input())
for i in range(T):
	(N, X) = map(int, input().split())
	R = N % 6
	A = int(N / 6)
	if R == 0:
		print(A * X)
	else:
		print((A + 1) * X)


import math
T = int(input())
for _ in range(T):
	(a, b) = list(map(int, input().split()))
	res = math.ceil(a / 6) * b
	print(res)


t = int(input())
while t != 0:
	(a, b) = map(int, input().split())
	s = a // 6
	d = a / 6
	if s == 0:
		print(b)
	elif s == d:
		print(b * s)
	else:
		print((s + 1) * b)
	t = t - 1


T = int(input())
for i in range(T):
	(N, X) = map(int, input().split())
	(a, b) = divmod(N, 6)
	c = X * a
	if b != 0:
		print(c + X)
	else:
		print(c)


import math
T = int(input())
for i in range(T):
	(N, X) = map(int, input().split())
	print(X * math.ceil(N / 6))


import math
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	if x <= 6:
		print(y)
	else:
		a = math.ceil(x / 6)
		b = a * y
		print(b)


t = int(input())
while t > 0:
	(n, x) = input().split()
	(n, x) = [int(n), int(x)]
	a = b = 0
	if n <= 6:
		print(x)
	else:
		a = n // 6
		b = n - a * 6
		if b != 0:
			print((a + 1) * x)
		else:
			print(a * x)
	t = t - 1


import math
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n <= 6:
		print(x)
	elif n % 6 == 0:
		print(n // 6 * x)
	else:
		print(math.ceil(n / 6) * x)


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


for i in range(int(input())):
	(n, x) = map(int, input().split())
	if n % 6 == 0:
		cost = n // 6 * x
	else:
		cost = (n // 6 + 1) * x
	print(cost)


for T in range(int(input())):
	(N, X) = map(int, input().split())
	if N >= 6:
		if N % 6 == 0:
			noOfSub = int(N / 6)
		else:
			noOfSub = int(N / 6) + 1
	else:
		noOfSub = 1
	print(noOfSub * X)


f = int(input())
for i in range(f):
	(m, x) = map(int, input().split())
	if m <= 6:
		print(x)
	elif m % 6 == 0:
		print(m // 6 * x)
	else:
		print((m // 6 + 1) * x)


import math
T = int(input())
for i in range(T):
	(N, X) = map(int, input().split())
	if N <= 6:
		print(X)
	elif N > 6:
		sub = math.ceil(N / 6)
		cost = X * sub
		print(cost)


import math
t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	print(math.ceil(n / 6) * x)
	t -= 1


import math
n = int(input())
for x in range(n):
	(h, y) = map(int, input().split())
	if h % 6 != 0:
		z = h / 6
		ans = math.ceil(z) * y
		print(ans)
	else:
		a = h / 6 * y
		a = int(a)
		print(a)


T = int(input())
for t in range(T):
	(N, X) = map(int, input().split())
	if N <= 6:
		print(X)
	elif N % 6 == 0:
		print(N // 6 * X)
	else:
		print((N // 6 + 1) * X)


import math
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n % 6 == 0:
		print(n // 6 * x)
	else:
		print((math.floor(n // 6) + 1) * x)


p = int(input())
for i in range(0, p):
	(z, y) = map(int, input().split())
	q = z % 6
	r = z // 6
	if q == 0:
		print(r * y)
	else:
		print((r + 1) * y)


T = int(input())
for i in range(T):
	(N, X) = map(int, input().split())
	if N <= 6:
		total = X
	if N % 6 == 0:
		total = N // 6
	else:
		total = N // 6 + 1
	harga = total * X
	print(harga)


import math
T = int(input())
for tc in range(T):
	(n, x) = map(int, input().split())
	y = n / 6
	z = math.ceil(y)
	print(z * x)


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


tc = int(input())
for i in range(tc):
	(n, cost) = map(int, input().split())
	sub = n // 6
	if n % 6 > 0:
		total_cost = (sub + 1) * cost
	else:
		total_cost = sub * cost
	print(total_cost)


import math
t = int(input())
for i in range(t):
	(N, X) = map(int, input().split())
	if N == 1:
		print(X)
	else:
		print(math.ceil(N / 6) * X)


n = int(input(''))
for i in range(n):
	(N, X) = map(int, input().split())
	if N <= 6:
		print(X)
	elif N % 6 == 0:
		print(N // 6 * X)
	else:
		print(N // 6 * X + X)


import math
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
for i in l:
	if i[0] <= 6:
		print(i[1])
	elif i[0] > 6:
		k = i[0] / 6
		l = math.ceil(k)
		print(l * i[1])