Most of the time when rounding a given number, it is customary to round to some multiple of a power of 10. However, there is no reason why we cannot use another multiple to do our rounding to. For example, you could round to the nearest multiple of 7, or the nearest multiple of 3.
Given an integer N and an integer B, round N to the nearest value which is a multiple of B. If N is exactly halfway between two multiples of B, return the larger value.

Input:- First line contains number of test cases and each test case two interger values N and B.

Ouput:- Print the desired output.

SAMPLE INPUT
3
5 10
4 10
100 3

SAMPLE OUTPUT
10
0
99

Explanation

Testcase 3:-100 is closer to 99 than 102.

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
if __name__=='__main__':
	T = int(input())
	for _ in range(T):
		num,m=list(map(int,input().split()))
		if num%m==0:
			print(num)
		else:
			k = num
			cnt1 = 0
			while True:
				if k%m==0:
					ans1 = k
					break
				cnt1 += 1
				k -= 1
			k = num
			cnt2 = 0
			while True:
				if k%m==0:
					ans2 = k
					break
				cnt2 += 1
				k += 1
			if cnt1<cnt2:
				print(ans1)
			else:
				print(ans2)
				


t = int(eval(input()))

while t:

	a , b = list(map(int,input().split()))

	m , n = a , a
	
	cnt_m , cnt_n = 0 , 0
	
	while m % b != 0:
		m -= 1
		cnt_m += 1

	while n % b != 0:
		n+=1
		cnt_n += 1

	if cnt_m > cnt_n :
		print(n)
	elif cnt_m < cnt_n :
		print(m)
	else :
		print((max(m,n)))

	t -= 1


import math
for _ in range(eval(input())):
	n, b = list(map(int, input().split()))
	x = n%b
	if x>=b/2.0:
		x = int(math.ceil(n/float(b)))
	else:
		x = int(n/float(b))
	print(x*b)