You are given $q$ queries in the following form:

Given three integers $l_i$, $r_i$ and $d_i$, find minimum positive integer $x_i$ such that it is divisible by $d_i$ and it does not belong to the segment $[l_i, r_i]$.

Can you answer all the queries?

Recall that a number $x$ belongs to segment $[l, r]$ if $l \le x \le r$.


-----Input-----

The first line contains one integer $q$ ($1 \le q \le 500$) — the number of queries.

Then $q$ lines follow, each containing a query given in the format $l_i$ $r_i$ $d_i$ ($1 \le l_i \le r_i \le 10^9$, $1 \le d_i \le 10^9$). $l_i$, $r_i$ and $d_i$ are integers.


-----Output-----

For each query print one integer: the answer to this query.


-----Example-----
Input
5
2 4 2
5 10 4
3 10 1
1 2 3
4 6 5

Output
6
4
1
3
10

Source: codeforces | Difficulty: EASY
Tags: Mathematics


Solutions:
q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	left = l // d * d
	if left == l:
		left -= d
	right = (r + d - 1) // d * d
	if right == r:
		right += d
	if not l <= d <= r:
		print(d)
	elif left > 0:
		print(left)
	else:
		print(right)


for z in range(int(input())):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	elif d > r:
		print(d)
	elif r // d == r / d:
		print((r // d + 1) * d)
	else:
		print(r // d * d + d)


def solve():
	q = int(input())
	for i in range(q):
		(l, r, d) = [int(s) for s in input().split()]
		if d < l:
			print(d)
		else:
			print(r + (d - r % d))
solve()


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	if l > d:
		print(d)
	elif r / d == 1:
		print(r + d)
	elif r / d < 1:
		print(d)
	elif r / d > 1:
		print((r // d + 1) * d)


import math
t = int(input())
for i in range(t):
	(l, r, d) = [int(i) for i in input().split()]
	if d < l:
		print(d)
	elif r < d:
		print(d)
	else:
		k = math.floor(r / d) + 1
		print(int(d * k))


for _ in range(int(input())):
	(l, r, d) = tuple(map(int, input().split()))
	if l % d == 0:
		if l // d > 1:
			print(d)
			continue
		else:
			pass
	elif l // d > 0:
		print(d)
		continue
	if r % d == 0:
		print(r + d)
	else:
		print(d * (r // d) + d)


n = eval(input())
res = 0
for i in range(n):
	(l, r, d) = map(int, input().strip().split())
	if d < l:
		print(d)
	elif l <= d and d <= r:
		res = r // d * d + d
		print(res)
	else:
		print(d)


q = int(input())
for _ in range(q):
	(l, r, d) = map(int, input().split())
	if d >= l:
		p = r // d + 1
		print(p * d)
	else:
		print(d)


for i in [0] * int(input()):
	(l, r, d) = map(int, input().split())
	print(d if l > d else (r // d + 1) * d)


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	(l, r, d) = mi()
	nl = d
	nr = r - r % d
	nr += d
	if nl < l:
		print(nl)
	else:
		print(nr)


def f():
	x = int(input())
	for xxx in range(x):
		(l, r, d) = map(int, input().split())
		if d < l or d > r:
			print(d)
		else:
			rem = r // d
			print(d + d * rem)
f()


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


num = int(input())
queries = []
for i in range(0, num):
	queries.append(list(map(int, input().split(' '))))
for i in range(0, num):
	d = queries[i][2]
	l = queries[i][0]
	r = queries[i][1]
	n = d
	while True:
		if n % d == 0:
			if n < l or n > r:
				print(n)
				break
			elif n >= l and n <= r:
				n += r - n
		n += d - n % d


n = int(input())
for i in range(n):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		op = r // d
		print((op + 1) * d)


n_queries = int(input())
for k in range(n_queries):
	(r, l, d) = list(map(int, input().split()))
	if d < r or d > l:
		print(d)
	else:
		print((l // d + 1) * d)


q = int(input())
for i in range(0, q):
	ln = [int(j) for j in input().split(' ')]
	l = ln[0]
	r = ln[1]
	d = ln[2]
	if d > r or d < l:
		print(d)
	else:
		print(r + (d - r % d))


from sys import stdin, stdout
t = int(stdin.readline())
for i in range(t):
	(l, r, d) = map(int, stdin.readline().split())
	if d < l:
		stdout.write(str(d))
		stdout.write('\n')
	else:
		stdout.write(str(d * (r // d + 1)))
		stdout.write('\n')


q = int(input())
for i in range(q):
	(l, r, d) = list(map(int, input().split()))
	if d < l:
		print(d)
	else:
		print(r // d * d + d)


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	temp = l // d
	if temp > 1:
		print(d)
	elif temp == 1 and l > d:
		print(d)
	else:
		if d > r:
			print(d)
			continue
		temp = r // d
		print((temp + 1) * d)


n = int(input())
for i in range(n):
	ch = input()
	l = ch.split()
	a = int(l[0])
	b = int(l[1])
	c = int(l[2])
	i = 0
	while True:
		i += 1
		d = c * i
		if d not in range(a, b + 1):
			print(d)
			break
		else:
			print(b // c * c + c)
			break


t = int(input())
for z in range(t):
	(l, r, n) = map(int, input().split())
	if n * 1 >= l and n * 1 <= r:
		c = r // n
		print(n * (c + 1))
	else:
		print(n * 1)


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	if l > d or r < d:
		print(d)
	else:
		t = r // d
		print((t + 1) * d)


q = int(input())
for i in range(q):
	data = input().split(' ')
	l = int(data[0])
	r = int(data[1])
	d = int(data[2])
	result = d if d < l else r + (d - r % d)
	print(result)


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	k = 1
	x = 0
	if d < l or d > r:
		print(d)
	else:
		kol = r // d + 1
		print(d * kol)


for _ in range(int(input())):
	tmp = list(map(int, input().split()))
	if tmp[2] not in range(tmp[0], tmp[1] + 1):
		print(tmp[2])
	else:
		print(tmp[1] + (tmp[2] - tmp[1] % tmp[2]))


q = int(input())
for u in range(q):
	[l, r, d] = list(map(int, input().split()))
	if d < l:
		print(d)
	else:
		print((r // d + 1) * d)


import sys
tc = int(sys.stdin.readline())
for _ in range(tc):
	(l, r, d) = map(int, sys.stdin.readline().split())
	left = l // d * d if l % d == 0 else (l // d + 1) * d
	right = r // d * d
	if d < l or d > r:
		print(d)
	else:
		temp = []
		if l <= left <= r and left - d > 0:
			temp.append(left - d)
		if l <= right <= r and right + d > 0:
			temp.append(right + d)
		if not temp:
			temp.append(d)
		temp.sort()
		print(temp[0])


q = int(input())
while q:
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	elif d > r:
		print(d)
	else:
		a = r // d
		print((a + 1) * d)
	q -= 1


def answer(l, r, d):
	if d < l:
		out = d
	else:
		amari = d - r % d
		out = r + amari
	return out
q = int(input())
for i in range(q):
	(l, r, d) = list(map(int, input().split(' ')))
	print(answer(l, r, d))


q = int(input())
A = [0] * q
for i in range(q):
	A[i] = input().split(' ')
for i in range(q):
	if int(A[i][2]) < int(A[i][0]) or int(A[i][2]) > int(A[i][1]):
		print(A[i][2])
	else:
		k = int(A[i][1]) // int(A[i][2])
		print((k + 1) * int(A[i][2]))


queries = int(input())
solutions = []
for query in range(queries):
	integersInput = input().split(' ')
	lowerLimit = int(integersInput[0])
	upperLimit = int(integersInput[1])
	divisor = int(integersInput[2])
	foundInteger = divisor
	if foundInteger >= lowerLimit and foundInteger <= upperLimit:
		if upperLimit % divisor == 0:
			foundInteger = upperLimit + divisor
		else:
			foundInteger = upperLimit + divisor - upperLimit % divisor
	solutions.append(foundInteger)
for solution in solutions:
	print(solution)


n = int(input())
for i in range(0, n):
	a = list(map(int, input().split()))
	if a[0] / a[2] > 1:
		d = a[0] % a[2]
		if a[0] / a[2] >= 2:
			print(a[2])
		elif d > 0:
			print(a[2])
		else:
			print((a[1] // a[2] + 1) * a[2])
	else:
		print((a[1] // a[2] + 1) * a[2])


t = int(input())
for i in range(t):
	(l, r, d) = list(map(int, input().split()))
	if d < l:
		print(d)
	elif d > r:
		print(d)
	else:
		print((r // d + 1) * d)


from sys import stdin, stdout
from math import *
from heapq import *
from collections import *

def main():
	q = int(stdin.readline())
	for _ in range(q):
		(l, r, d) = [int(x) for x in stdin.readline().split()]
		res = 0
		if d < l:
			res = d
		else:
			res = (trunc(r / d) + 1) * d
		stdout.write(str(res) + '\n')
	return 0
main()


def main():
	q = int(input())
	for i in range(q):
		(l, r, d) = map(int, input().split())
		if d < l:
			print(d)
		else:
			print(r - r % d + d)
main()


t = int(input())
for i in range(t):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		print(r // d * d + d)


N = int(input())
for i in range(N):
	(l, r, d) = [int(u) for u in input().split()]
	if l * 1.0 / d > 1:
		print(d)
	else:
		print(d * (r // d) + d)


from math import *
q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	num1 = (ceil(l / d) - 1) * d
	num2 = (r // d + 1) * d
	if num1 > 0:
		print(d)
	else:
		print(num2)


def find(l, r, d):
	if l > d or r < d:
		return d
	return r + (d - r % d)
n = int(input())
for _ in range(n):
	(l, r, d) = map(int, input().split())
	print(find(l, r, d))


def Spider():
	(a, b, c) = map(int, input().split())
	if c < a or c > b:
		print(c)
	else:
		print((int(b / c) + 1) * c)
TIMES = 1
TIMES = int(input())
for TIME_TEMP in range(TIMES):
	Spider()


q = int(input())
queries_list = []
for i in range(1, q + 1):
	queries_list.append(input().split())
for query in queries_list:
	x = int(query[2])
	d = int(query[2])
	r = int(query[1])
	l = int(query[0])
	if d < l or d > r:
		print(d)
	else:
		print(int(int(r / d + 1) * d))


def verificar(l, r, d):
	x = d
	n = int(r / d)
	while (l <= x <= r) == True:
		n += 1
		x = d * n
	return x
n = int(input())
valores = []
while n != 0:
	entrada = input()
	valores.append(entrada)
	n = n - 1
for i in valores:
	j = i.split(' ')
	print(verificar(int(j[0]), int(j[1]), int(j[2])))


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	z1 = d * (l // d)
	if l % d == 0:
		z1 -= d
	z2 = d * (r // d + 1)
	if z1 < 1:
		print(z2)
	else:
		print(d)


import sys
import math
import bisect

def solve(l, r, d):
	if l > d:
		return d
	val = r + 1
	ans = (val + d - 1) // d * d
	return ans

def main():
	for _ in range(int(input())):
		(l, r, d) = map(int, input().split())
		print(solve(l, r, d))
main()


def min_ints(l, r, d):
	if d < l:
		print(d)
		return
	else:
		print((r // d + 1) * d)
		return
n = int(input())
for _ in range(n):
	(l, r, d) = list(map(int, input().split()))
	min_ints(l, r, d)


Q = int(input())
for i in range(Q):
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		print(d)
	else:
		print(r + d - r % d)


def main():
	buf = input()
	q = int(buf)
	l = []
	r = []
	d = []
	for i in range(q):
		buf = input()
		buflist = buf.split()
		l.append(int(buflist[0]))
		r.append(int(buflist[1]))
		d.append(int(buflist[2]))
	for i in range(q):
		if d[i] < l[i]:
			print(d[i])
		else:
			print(d[i] * (r[i] // d[i] + 1))
main()


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
		continue
	x = d
	if x <= r:
		mod = r % d
		x = r - mod + d
	print(x)


q = int(input())
for i in range(q):
	s = input().split()
	(l, r, d) = (int(s[0]), int(s[1]), int(s[2]))
	if d < l:
		print(d)
		continue
	u = r - r % d + d
	print(u)


import re, math, decimal, bisect

def read():
	return input().strip()

def iread():
	return int(input().strip())

def viread():
	return [int(_) for _ in input().strip().split()]
for _ in range(iread()):
	(l, r, d) = viread()
	ans1 = r + 1
	if d != 1:
		ans1 += (d - ans1 % d) % d
	ans2 = d
	print(ans1 if ans2 >= l and ans2 <= r else ans2)


q = int(input())
while q > 0:
	(l, r, d) = map(int, input().split())
	if l > d:
		print(d)
	elif d >= l and d <= r:
		print(r + d - r % d)
	else:
		print(d)
	q = q - 1


def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
for _ in range(ii()):
	(l, r, d) = mi()
	ans = d
	if l <= d <= r:
		ans = d * (r // d + 1)
	print(ans)


q = int(input())
results = []
for i in range(q):
	(l, r, d) = map(int, input().split())
	temp = d
	if temp < l or temp > r:
		results.append(temp)
	else:
		n = r // d
		temp += n * d
		results.append(temp)
for (j, temp) in enumerate(results):
	print(temp)


x = int(input())
for i in range(x):
	a = input().split(' ')
	b = list(map(int, a))
	t = b[0] % b[2]
	p = int(b[0] / b[2])
	if t != 0:
		if p >= 1:
			req = b[2]
		else:
			req = b[1] + (b[2] - b[1] % b[2])
	elif b[0] - b[2] > 0:
		req = b[2]
	else:
		req = b[1] + (b[2] - b[1] % b[2])
	print(req)


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	elif d <= r:
		print(r + d - r % d)
	elif d > r:
		print(d)


n = int(input())
for i in range(n):
	(a, b, c) = list(map(int, input().split()))
	if a > c:
		print(c)
	else:
		print((b + c) // c * c)


q = int(input())
for _ in range(q):
	(l, r, d) = map(int, input().split())
	if d == 1:
		if l != 1:
			print(1)
		else:
			print(r + 1)
	else:
		if l % d == 0:
			check = l // d - 1
		else:
			check = l // d
		check2 = r // d + 1
		if check > 0:
			print(d)
		else:
			print(check2 * d)


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		k = d * (r // d)
		while k <= r:
			k += d
		print(k)


q = int(input())
for i in range(q):
	ls = list(map(int, input().split()))
	l = ls[0]
	r = ls[1]
	d = ls[2]
	if d < l:
		print(d)
	else:
		print((r // d + 1) * d)


t = int(input())
for i in range(t):
	s = list(map(int, input().split(' ')))
	l = s[0]
	r = s[1]
	d = s[2]
	if d < l:
		print(d)
	else:
		k = (r + 1) // d
		rm = (r + 1) % d
		if rm == 0:
			print(r + 1)
		else:
			print((k + 1) * d)


import math

def main():
	q = int(input())
	for i in range(q):
		(l, r, d) = map(int, input().split())
		if l % d == 0:
			l -= 1
		if l >= d:
			x = d
		else:
			if r % d == 0:
				r += 1
			x = int(d * math.ceil(r / d))
		print(x)
main()


q = int(input())
for i in range(q):
	(x, l, d) = input().split()
	x = int(x)
	l = int(l)
	d = int(d)
	if d < x or d > l:
		ans = d
	else:
		a = l % d
		b = l + (d - a)
		ans = b
	print(ans)


t = int(input())
while t > 0:
	(l, r, d) = [int(x) for x in input().split()]
	if d < l or d > r:
		print(d)
	else:
		print(r // d * d + d)
	t -= 1


t = int(input())
for case in range(t):
	(l, r, d) = [int(x) for x in input().split(' ')]
	if d < l:
		ans = d
	else:
		ans = d * (r // d + 1)
	print(ans)


def minimum_integer():
	cases = int(input())
	integers = []
	for i in range(cases):
		integers.append(list(map(int, input().split())))
	for i in range(len(integers)):
		if integers[i][2] < integers[i][0] and integers[i][2] < integers[i][1]:
			print(integers[i][2])
			continue
		elif integers[i][2] > integers[i][0] and integers[i][2] > integers[i][1]:
			print(integers[i][2])
			continue
		temp = integers[i][2]
		L = 1
		R = integers[i][1] * 2
		found = False
		while L <= R:
			mid = L + int((R - L) / 2)
			if int(temp * mid) > integers[i][1]:
				R = mid - 1
			elif int(temp * mid) < integers[i][1]:
				L = mid + 1
			elif int(temp * mid) == integers[i][1]:
				print(temp * (mid + 1))
				found = True
				break
		if not found:
			if temp * mid < integers[i][1]:
				print(int(temp * (mid + 1)))
			else:
				print(int(temp * mid))
minimum_integer()


q = int(input())
for _ in range(q):
	(l, r, d) = map(int, input().split())
	m = l / d
	z = r // d
	if m > 1:
		print(d)
	else:
		print(d * (z + 1))


record = []
query = int(input())
for i in range(query):
	record.append(input())
for values in record:
	(li, ri, di) = map(int, values.split())
	contain = None
	if di < li or di > ri:
		contain = di
	else:
		multiplier = ri // di + 1
		contain = di * multiplier
	print(contain)


t = int(input())
while t:
	t = t - 1
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	i = int(c)
	if c < a or c > b:
		print(c)
	else:
		if c * 2 >= a:
			i = b - b % c
		while 1:
			i = i + c
			if i < a or i > b:
				print(i)
				break


class CodeforcesTask1101ASolution:

	def __init__(self):
		self.result = ''
		self.q = 0
		self.queries = []

	def read_input(self):
		self.q = int(input())
		for x in range(self.q):
			self.queries.append([int(y) for y in input().split(' ')])

	def process_task(self):
		results = []
		for query in self.queries:
			x = query[2]
			if x < query[0]:
				results.append(x)
			else:
				x = query[2] * (query[1] // query[2] + 1)
				results.append(x)
		self.result = '\n'.join([str(x) for x in results])

	def get_result(self):
		return self.result
Solution = CodeforcesTask1101ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


q = int(input())
ans = []
for i in range(q):
	(l, r, d) = map(int, input().split())
	j = 1
	if d < l or d > r:
		ans.append(d)
	else:
		ans.append((r // d + 1) * d)
for i in range(q):
	print(ans[i])


n = int(input())
for h in range(0, n):
	(a, b, c) = map(int, input().split(' '))
	if a <= c and c <= b:
		u = b - b % c + c
		print(u)
	else:
		print(c)


q = int(input())
for _ in range(q):
	(l, r, d) = [int(x) for x in input().split()]
	c = 0
	if d < l:
		print(d)
		continue
	i = r // d * d + d
	print(i)


n = int(input())
for i in range(n):
	(l, r, d) = input().split(' ')
	(l, r, d) = (int(l), int(r), int(d))
	checker = True
	fac = 1
	if r >= d >= l:
		print(d * (int(r / d) + 1))
	else:
		print(d)


n = int(input())
for _ in range(n):
	(l, r, d) = input().split()
	(l, r, d) = (int(l), int(r), int(d))
	if d < l:
		print(d)
	elif d > r:
		print(d)
	else:
		k = int(r / d)
		k = k + 1
		print(d * k)


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


for i in range(int(input())):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		a = r // d
		print((a + 1) * d)


nQ = int(input())
for q in range(nQ):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		print(r // d * d + d)


q = int(input())
for _ in range(q):
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		print(d)
	else:
		print(r // d * d + d)


t = int(input())
for _ in range(t):
	(l, r, d) = map(int, input().split())
	s = d * (l // d)
	e = d * (r // d) + d
	f = 0
	for i in range(d, s + 1, d):
		if i < l and i % d == 0:
			print(i)
			f = 1
			break
	if f == 0:
		print(e)


for _ in range(int(input())):
	(l, r, d) = [int(x) for x in input().split()]
	if l % d == 0:
		num1 = l // d
		num1 -= 1
	else:
		num1 = l // d
	num2 = r // d
	num2 += 1
	if num1 >= 1:
		print(d)
		continue
	else:
		print(num2 * d)
		continue


from sys import stdin, stdout
from math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial
from random import randint
q = int(stdin.readline())
for i in range(q):
	(l, r, d) = map(int, stdin.readline().split())
	if d < l:
		stdout.write(str(d) + '\n')
	else:
		stdout.write(str((r // d + 1) * d) + '\n')


n = int(input())
for i in range(n):
	a = [int(s) for s in input().split()]
	l = a[0]
	r = a[1]
	d = a[2]
	if d <= r and d >= l:
		print((r // d + 1) * d)
	else:
		print(d)


import sys

def rint():
	return map(int, sys.stdin.readline().split())
q = int(input())
for i in range(q):
	(l, r, d) = rint()
	if l > d:
		print(d)
	elif r % d == 0:
		print(r + d)
	else:
		print(r // d * d + d)


t = int(input())
for _ in range(t):
	l1 = [int(x) for x in input().split()]
	(l, r, d) = (l1[0], l1[1], l1[2])
	if d < l:
		print(d)
	else:
		print(r + d - r % d)


import sys
from collections import defaultdict as dd
input = sys.stdin.readline
n = int(input())
for i in range(n):
	(l, r, d) = map(int, input().split())
	if d * 1 < l:
		print(d * 1)
	else:
		print((r // d + 1) * d)


import math

class Triple:

	def __init__(self, l, r, d):
		self.l = l
		self.r = r
		self.d = d

	def find_integer(self):
		if self.d < self.l or self.d > self.r:
			return self.d
		if self.r % self.d == 0:
			return self.d * (int(math.ceil(self.r / self.d)) + 1)
		return self.d * int(math.ceil(self.r / self.d))
q = int(input())
numbers = []
for i in range(0, q):
	(l, r, d) = [int(s) for s in input().split(' ')]
	numbers.append(Triple(l, r, d))
for triple in numbers:
	print(triple.find_integer())


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	(l, r) = (min(l, r), max(l, r))
	temp1 = l // d
	temp2 = r // d
	if d * temp1 == l:
		temp1 -= 1
	if d * temp2 <= r:
		temp2 += 1
	flag = 0
	for q in range(1, temp1 + 1):
		print(d * q)
		flag = 1
		break
	if flag:
		continue
	print(d * temp2)


import math
q = int(input())
for _ in range(q):
	(l, r, d) = map(int, input().split())
	n = l / d
	m = r / d
	if n > 1:
		print(d)
	elif math.ceil(m) == m:
		print(int((m + 1) * d))
	else:
		print(d * math.ceil(m))


def min_int(inp):
	l = int(inp[0])
	r = int(inp[1])
	d = int(inp[2])
	out = -1
	i = 1
	while out == -1:
		mult = i * d
		if mult not in range(l, r + 1):
			out = mult
			break
		if mult in range(l, r + 1):
			mult = r
			i = mult // d
		i = i + 1
	return out
q = int(input())
for i in range(0, q):
	inp = input()
	inp = inp.split()
	minimal_integer = min_int(inp)
	print(minimal_integer)


def func():
	q = int(input())
	while q:
		(l, r, d) = map(int, input().split())
		if d >= l and d <= r:
			k = r // d
			ans = d * (k + 1)
		else:
			ans = d
		print(ans)
		q -= 1
func()


for _ in range(int(input())):
	f = 0
	(l, r, d) = map(int, input().split())
	if l > d:
		print(d)
	elif d > r:
		print(d)
	else:
		print(r + d - r % d if r % d != 0 else r + d)


q = int(input())
L = [0] * q
R = [0] * q
D = [0] * q
for i in range(q):
	entrada = str(input()).split()
	L[i] = int(entrada[0])
	R[i] = int(entrada[1])
	D[i] = int(entrada[2])

def find_x(l, r, d):
	result = d
	if l <= d <= r:
		if r % d == 0:
			result = r + d
		else:
			result = int(r / d) * d + d
	return result
for i in range(q):
	print(find_x(L[i], R[i], D[i]))


def MinimumInteger(l, r, d):
	if d < l:
		return d % l
	else:
		return r + (d - r % d)
q = int(input())
result = ''
while q > 0:
	(l, r, d) = [int(x) for x in input().split()]
	result += str(MinimumInteger(l, r, d))
	if q > 1:
		result += '\n'
	q -= 1
print(result)


from math import ceil, log
q = int(input().strip())
while q > 0:
	(l, r, d) = map(int, input().strip().split())
	if d < l:
		print(d)
	elif d == 1:
		print(r + 1)
	else:
		print(r // d * d + d)
	q -= 1


n = int(input())
for _ in range(n):
	numbers = [int(i) for i in input().split()]
	l = numbers[0]
	r = numbers[1]
	d = numbers[2]
	if d < l or d > r:
		print(d)
	else:
		print((r // d + 1) * d)


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	d1 = d * 1
	if d1 < l:
		print(d)
	elif d > r:
		print(d)
	else:
		l = r // d
		print(d * (l + 1))


nb = int(input())
liste = []
roger = True
for loop in range(nb):
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		print(d)
	else:
		print(r // d * d + d)


q = int(input())
while q:
	[l, r, d] = list(map(int, input().split()))
	minimum = 0
	if d <= l - 1:
		minimum = d
	elif d <= r:
		minimum = (r // d + 1) * d
	else:
		minimum = d
	print(minimum)
	q -= 1


def solution(query):
	(l, r, d) = query
	if d < l:
		return d
	else:
		i = 1
		if d < r:
			i = int(r / d)
		while i * d <= r:
			i += 1
		return i * d
n = int(input())
for i in range(n):
	query = list(map(int, input().split()))
	print(solution(query))


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


q = int(input())
result = []
for i in range(q):
	(l, r, d) = map(int, input().split())
	if d < l:
		result.append(d)
	elif d > r:
		result.append(d)
	else:
		c = r // d * d
		while c <= r:
			c += d
		result.append(c)
for i in result:
	print(i)


n = int(input())
for i in range(n):
	(l, r, d) = map(int, input().split())
	if l / d > 1:
		print(d)
		continue
	print(r + d - r % d)


def main():
	q = int(input())
	ans = []
	for i in range(q):
		inp = input().split()
		li = int(inp[0])
		r = int(inp[1])
		d = int(inp[2])
		ii = 1
		global s
		s = True
		if d < li:
			ans.append(d)
		elif d > r:
			ans.append(d)
		else:
			ans.append((int(r / d) + 1) * d)
	for i in range(q):
		print(ans[i])
main()


T = int(input())
for t in range(T):
	(l, r, d) = [int(x) for x in input().split()]
	if d < l or d > r:
		print(d)
	else:
		remainder = (r + 1) % d
		addend = d - remainder if remainder != 0 else 0
		print(r + 1 + addend if remainder != 0 else r + 1)


def main():
	query_num = int(input())
	for _ in range(query_num):
		(l, r, d) = map(int, input().split())
		if l > d:
			ret = d
		else:
			ret = r // d * d + d
		print(ret)
main()


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		m = r % d
		if r < d:
			print(d)
		else:
			x = r // d
			print(d * (x + 1))


q = int(input())
for _ in range(q):
	ln = list(map(int, input().split()))
	i = 1
	if ln[2] < ln[0]:
		print(ln[2])
	elif ln[2] > ln[1]:
		print(ln[2])
	else:
		x = ln[1] - ln[2]
		print(ln[1] + (ln[2] - x % ln[2]))


Q = int(input())
for i in range(Q):
	(l, r, d) = map(int, input().split())
	ans = d
	if ans >= l:
		ans = (r // d + 1) * d
	print(ans)


x = int(input())
for i in range(x):
	(a, b, c) = map(int, input().split())
	if a > c:
		print(c * 1)
	else:
		print((b // c + 1) * c)


q = int(input())
l = []
for i in range(q):
	k = input().split()
	l.append(k)
for j in l:
	l = int(j[0])
	r = int(j[1])
	d = int(j[2])
	if d < r:
		if d >= l:
			a = d - r % d
			if a == 0:
				print(r + d)
			else:
				print(r + a)
		elif l > d:
			print(d)
	elif d > r:
		print(d)
	elif d == r:
		print(2 * d)


n = int(input())
for i in range(n):
	s = list(map(int, input().split()))
	if s[0] > s[2]:
		print(s[2])
	elif s[2] >= s[0] and s[0] <= s[1]:
		q = s[2]
		b = s[1]
		q = b // q * q + q
		print(q)
	else:
		print(q)


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import PriorityQueue as pq
for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	(x, y) = (l // d, r // d)
	if l > d:
		print(d)
	else:
		print((y + 1) * d)


num = int(input())
for i in range(num):
	(l, r, d) = tuple(map(int, input().split()))
	if d < l or d > r:
		print(d)
	else:
		print((1 + int(r / d)) * d)


p = int(input())
de = []
for i in range(p):
	x = input().split(' ')
	l = int(x[0])
	r = int(x[1])
	d = int(x[2])
	de.append((l, r, d))
for (l, r, d) in de:
	if l <= d <= r:
		x = (r // d + 1) * d
	else:
		x = d
	print(x)


n = int(input())
for i in range(n):
	(l, r, d) = map(int, input().split())
	if not (d <= r and d >= l):
		print(d)
	else:
		p = (r - d) // d + 1
		print(d + d * p)


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	u = d
	if u < l:
		print(u)
		continue
	u = r // d * d + d
	print(u)


from math import ceil

def compute_minimum_int(input_data):
	for i in range(len(input_data)):
		input_data[i] = int(input_data[i])
	x = input_data[:-1]
	d = input_data[2]
	x.sort()
	if not (d >= x[0] and d <= x[1]):
		return d
	z = x[1] / d
	y = ceil(x[1] / d)
	if z == y:
		y += 1
	return d * y
inputs = []
inputs_num = int(input())
while inputs_num > 0:
	input_data = input().split(' ')
	inputs.append(input_data)
	inputs_num -= 1
for i in inputs:
	print(compute_minimum_int(i))


n = int(input())
for i in range(0, n):
	lrd = input().split()
	l = int(lrd[0])
	r = int(lrd[1])
	d = int(lrd[2])
	if d < l:
		print(d)
	else:
		print(r + (d - r % d))


n = int(input())
for i in range(n):
	(l, r, d) = map(int, input().split())
	t = 0
	for i in range(1, l // d + 1):
		q = d * i
		if (q < l or q > r) and q != 0:
			t += 1
			print(q)
			break
	if t == 0:
		for i in range(r // d, r // d + 5):
			q = d * i
			if (q < l or q > r) and q != 0:
				print(q)
				break


q = int(input())
for i in range(q):
	(l, r, d) = [int(x) for x in input().split()]
	if d < l:
		print(d)
	elif d >= l:
		aux = (r // d + 1) * d
		print(aux)


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = int(input())
for tt in range(t):
	(l, r, d) = map(int, sys.stdin.readline().split(' '))
	v2 = r // d
	v2 += 1
	if d < l or d > r:
		print(d)
	else:
		print(v2 * d)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


n = int(input())
A = []
for i in range(n):
	A = A + [input().split()]
for a in A:
	if int(a[2]) < int(a[0]) or int(a[2]) > int(a[1]):
		print(a[2])
	else:
		print(int(a[2]) * (int(a[1]) // int(a[2]) + 1))


q = int(input())
for _ in range(q):
	(l, r, d) = [int(x) for x in input().split()]
	if d < l or d > r:
		print(d)
	else:
		print((r // d + 1) * d)


import sys
import math

def read_int():
	return int(input().strip())

def read_int_list():
	return list(map(int, input().strip().split()))

def read_string():
	return input().strip()

def read_string_list(delim=' '):
	return input().strip().split(delim)
q = read_int()
for _ in range(q):
	[l, r, d] = read_int_list()
	if d < l:
		print(d)
		continue
	if d > r:
		print(d)
		continue
	temp = (l // d - 1) * d
	if temp < l and temp >= d:
		print(temp)
		continue
	temp = (r // d + 1) * d
	if temp > r and temp >= d:
		print(temp)
		continue


a = int(input())
res = 0
j = []
for i in range(0, a):
	(x, y, z) = list(map(int, input().split()))
	if z < x or z > y:
		res = z
	else:
		res = (y // z + 1) * z
	j.append(res)
print(*j, sep='\n')


T = int(input())
for cas in range(T):
	(l, r, d) = map(int, input().split())
	if l > d:
		print(d)
	else:
		print(r // d * d + d)


Q = int(input())
for i in range(Q):
	arr = input()
	(L, R, D) = [int(x) for x in arr.split(' ')]
	if D < L:
		print(D)
	elif R % D == 0:
		print(R + D)
	else:
		print(R // D * D + D)


t = int(input())
for x in range(t):
	a = [int(x) for x in input().split()]
	s = a[2]
	if s < a[0]:
		print(s)
	elif s > a[1]:
		print(s)
	else:
		print(s * (int(a[1] / s) + 1))


for _ in range(int(input())):
	(l, r, d) = list(map(int, input().split()))
	if d < l:
		print(d)
	else:
		k = r // d
		print((k + 1) * d)


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	if not l <= d <= r:
		print(d)
	else:
		print((r // d + 1) * d)


from math import *
q = int(input())
print()
for i in range(q):
	s = input()
	(left, r, d) = s.split()
	left = float(left)
	r = float(r)
	d = float(d)
	if left / d > 1 or r / d < 1:
		print(int(d))
	else:
		print(int(d * (floor(r / d) + 1)))


for i in range(int(input())):
	(left, right, d) = map(int, input().split())
	ans = (d if left > d else 0) or (right // d + 1) * d
	print(ans if ans > 0 else -1)


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


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	if d >= l and d <= r:
		print((r // d + 1) * d)
	else:
		print(d)


import math
for t in range(int(input())):
	(l, r, d) = [int(x) for x in input().split(' ')]
	if d < l or d > r:
		print(d)
	elif r % d == 0:
		print(int((r / d + 1) * d))
	else:
		print(int(math.ceil(r / d) * d))


q = int(input())
for qi in range(q):
	(li, ri, di) = list(map(int, input().split()))
	if di < li:
		print(di)
	else:
		print((ri // di + 1) * di)


for i in int(input()) * [0]:
	l = list(map(int, input().split()))
	if l[2] >= l[0]:
		z = l[2] * (0 - -l[1] // l[2])
		if z > l[1]:
			print(z)
		else:
			print(z + l[2])
	else:
		print(l[2])


q = int(input())
result = []
for i in range(q):
	(l, r, d) = map(int, input().split())
	if l // d > 1 and l % d == 0:
		result.append(str(d))
	elif l // d >= 1 and l % d != 0:
		result.append(str(d))
	else:
		result.append(str((r // d + 1) * d))
print('\n'.join(result))


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	if l % d == 0:
		a = l // d - 1
	else:
		a = l // d
	b = r // d + 1
	if a == 0:
		print(b * d)
	else:
		print(d)


def cin():
	n = int(input())
	return n
n = cin()
for i in range(n):
	(l, r, d) = list(map(int, input().split()))
	if l > d:
		print(d)
	else:
		R = r + d
		print(R - R % d)


n = int(input())
a = []
for i in range(n):
	(l, r, d) = map(int, input().split())
	a.append([l, r, d])
for i in a:
	(l, r, d) = list(i)
	if d < l:
		print(d)
	else:
		c = r // d
		print((c + 1) * d)


n = int(input())
for _ in range(n):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		i = max(r // d, 1)
		while l <= i * d <= r:
			i += 1
		print(i * d)


tes = int(input())
for t in range(tes):
	a = [int(x) for x in input().split()]
	li = a[0]
	ri = a[1]
	di = a[2]
	done = 1
	i = 1
	if di > ri:
		xi = di
	elif di < li:
		xi = di
	else:
		z = ri // di
		xi = di * (z + 1)
	print(xi)


n = int(input())
for i in range(n):
	(l, r, d) = tuple(map(int, input().split()))
	if l > d:
		print(d)
	else:
		x = (r // d + 1) * d
		print(x)


t = int(input())
for _ in range(t):
	(l, r, d) = map(int, input().strip().split())
	if l > d:
		print(d)
	else:
		k = r // d
		k = (k + 1) * d
		print(k)


import math
t = int(input())
for ii in range(t):
	(a, b, c) = map(int, input().split())
	if c < a or c > b:
		print(c)
	elif b % c == 0:
		print(c * (b // c + 1))
	else:
		print(c * math.ceil(b / c))


q = int(input())
a = []
for i in range(0, q):
	(l, r, m) = map(int, input().split())
	if m < l:
		a.append(m)
	else:
		a.append((r // m + 1) * m)
for i in range(0, len(a)):
	print(a[i])


def readInput():
	Q = int(input())
	lista = list()
	for i in range(Q):
		(l, r, d) = map(int, input().split())
		lista.append([l, r, d])
	return (Q, lista)

def solve(l, r, d):
	upValue = r // d + 1
	downValue = (l + d - 1) // d - 1
	if downValue <= 0:
		return upValue * d
	else:
		return d

def solveProblem():
	(Q, queries) = readInput()
	assert Q == len(queries)
	for i in range(Q):
		print(solve(queries[i][0], queries[i][1], queries[i][2]))
solveProblem()


for i in range(int(input())):
	(a, b, d) = map(int, input().split())
	if a / d > 1:
		print(d)
	else:
		print(d * (b // d + 1))


t = int(input())
for i in range(t):
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		print(d)
	elif r % d == 0:
		print(r + d)
	else:
		x = r // d * d + d
		print(x)


a = int(input())
for i in range(a):
	b = list((int(x) for x in input().split()))
	l = b[0]
	r = b[1]
	d = b[2]
	if l > d:
		print(d)
	elif d > r:
		print(d)
	else:
		print(d * (r // d + 1))


def doit(d):
	if d < l:
		return d
	elif r % d == 0:
		return r + d
	else:
		return r + d - r % d
q = int(input())
for t in range(q):
	[l, r, d] = [int(i) for i in input().split()]
	print(doit(d))


import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
from collections import defaultdict
from math import sqrt
INF = pow(2, 63)

def isPrime(number):
	assert isinstance(number, int) and number >= 0, "'number' must been an int and positive"
	status = True
	if number <= 1:
		status = False
	for divisor in range(2, int(round(sqrt(number))) + 1):
		if number % divisor == 0:
			status = False
			break
	assert isinstance(status, bool), "'status' must been from type bool"
	return status

def prime_factors(n: int):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return factors

def greatest_common_divisor(a: int, b: int) -> int:
	return abs(b) if a == 0 else greatest_common_divisor(b % a, a)

def solveb(n, tuparr):
	return -1
import math

def solve(l, r, d):
	if l // d > 0 and l != d:
		return d
	return d * (r // d + 1)

def main():
	n = int(input().strip())
	for _ in range(n):
		print(solve(*list(map(int, input().strip().split()))))

def mainb():
	pass
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline()
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


from math import ceil
n = int(input())
for i in range(n):
	[l, r, d] = [int(j) for j in input().split()]
	if l > d:
		print(d)
	else:
		k = ceil(r / d) * d
		print(k + d if k == r else k)


def calculo(l, r, d):
	if d < l:
		return d
	else:
		return (r // d + 1) * d
entrada = int(input())
for i in range(entrada):
	valor = list(map(int, input().split()))
	print(calculo(valor[0], valor[1], valor[2]))


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	if d < min(l, r):
		print(d)
	else:
		print((max(l, r) + d) // d * d)


original_length = int(input())
questions = []
for x in range(original_length):
	questions.append([int(y) for y in input().split()])
for i in questions:
	d = int(i[2])
	if d >= i[0]:
		print((i[1] // d + 1) * d)
	else:
		print(d)


q = int(input())
for _ in range(q):
	(l, r, d) = list(map(int, input().split()))
	if d < l or d > r:
		print(d)
	else:
		div = r // d
		print(d * (div + 1))


import sys
import math
from collections import defaultdict, deque
input = sys.stdin.readline

def inar():
	return [int(el) for el in input().split()]

def main():
	t = int(input())
	for _ in range(t):
		(l, r, d) = inar()
		if l <= d <= r:
			print(d * (r // d + 1))
		else:
			print(d)
main()


n = int(input())
for i in range(0, n):
	p = input().rstrip().split(' ')
	l = int(p[0])
	r = int(p[1])
	d = int(p[2])
	t = d * 1
	j = 1
	U = 0
	while t < l:
		if t < l and t < r:
			U = 1
			break
		if t > l and t > r:
			U = 1
			break
		j += 1
		t = d * j
	if U == 1:
		print(t)
	else:
		g = r // d + 1
		t = d * g
		while t > r:
			if t < l and t < r:
				U = 1
				break
			if t > l and t > r:
				U = 1
				break
			g += 1
			t = d * g
		print(t)


def get_minimum(l, r, d, x):
	minimum = x * d
	if not (minimum < l or minimum > r):
		minimum = get_minimum(l, r, d, int(r / d) + 1)
	return minimum

def min_integer(queries):
	results = []
	for query in queries:
		(l, r, d) = query
		results.append(get_minimum(l, r, d, 1))
	return results

def get_queries(q):
	queries = []
	while q > 0:
		(l, r, d) = input().split(' ')
		(l, r, d) = (int(l), int(r), int(d))
		queries.append([l, r, d])
		q -= 1
	return queries
queries = get_queries(int(input()))
results = min_integer(queries)
for r in results:
	print(r)


q = int(input())
result = []
for _ in range(q):
	(l, r, d) = map(int, input().strip().split())
	if d < l or d > r:
		result.append(d)
		continue
	m = r // d
	res = d * (m + 1)
	result.append(res)
for i in result:
	print(i)


TC = int(input())
for T in range(TC):
	(l, r, d) = map(int, input().split())
	res = d
	if l <= res <= r:
		res = (r // d + 1) * d
	print(res)


q = int(input())
for i in range(q):
	a = input().split()
	if int(a[2]) > int(a[1]) or int(a[2]) < int(a[0]):
		print(a[2])
	else:
		s = int(a[1]) // int(a[2])
		print((s + 1) * int(a[2]))


for i in range(int(input())):
	(l, r, d) = map(int, input().split(' '))
	if l - d > 0:
		print(d)
	elif r < d:
		print(d)
	elif d >= l and d <= r:
		m = int(r / d) + 1
		print(d * m)


for _ in range(int(input())):
	(l, r, d) = list(map(int, input().split()))
	res = d
	if l <= res <= r:
		res = d * (r // d) + d
	print(res)


t = int(input())
for _ in range(t):
	(n, k, m) = map(int, input().split())
	if m < n:
		print(m)
	elif m > k:
		print(m)
	else:
		d = k - m
		e = d // m
		f = m * (e + 2)
		print(f)


import math
q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		print(d)
	elif (r + 1) % d == 0:
		print(r + 1)
	else:
		print(r + 1 - (r + 1) % d + d)


import bisect
from sys import stdin
q = int(stdin.readline())
for _ in range(q):
	(l, r, d) = map(int, stdin.readline().split())
	if l <= d:
		if d > r:
			print(d)
		elif d == r:
			print(2 * d)
		else:
			(x, y) = divmod(r + 1, d)
			if y == 0:
				print(r + 1)
			else:
				print(d * (x + 1))
	else:
		print(d)


n = int(input())
for i in range(n):
	(l, r, d) = map(int, input().split())
	if r >= d and d > l:
		print(d * (r // d + 1))
	elif r > d and l >= d:
		if l == d:
			print(d * (r // d + 1))
		else:
			print(d)
	elif r < d:
		print(d)
	elif r == l and l == d:
		print(d * 2)


q = int(input())
for _ in range(0, q):
	(l, r, n) = map(int, input().split())
	if n < l:
		div = l // n
		rem = l % n
		if rem == 0:
			ans = l - n * (div - 1)
		else:
			ans = l - rem
			rem = ans % n
			div = ans // n
			l = ans
			if rem == 0:
				ans = l - n * (div - 1)
	elif n > r:
		ans = n
	elif n == r:
		ans = 2 * n
	elif n < r:
		rem = r % n
		if rem == 0:
			ans = r + n
		else:
			div = r // n
			ans = (div + 1) * n
	print(ans)


for i in [0] * int(input()):
	a = list((int(x) for x in input().split()))
	print((a[2] >= a[0]) * (a[1] // a[2]) * a[2] + a[2])


n = int(input())
for i in range(n):
	(a, b, d) = map(int, input().split())
	if d < a:
		print(d)
	else:
		c = b % d
		if c == 0:
			print(b + d)
		else:
			print(b + (d - c))


def funcao(l, r, d):
	if d < l or d > r:
		return d
	else:
		m = int(r / d)
		return (m + 1) * d
q = int(input())
lista = []
for e in range(q):
	lista.append(input().split())
for e in lista:
	l = int(e[0])
	r = int(e[1])
	d = int(e[2])
	print(funcao(l, r, d))


from math import ceil
for q in range(int(input())):
	(a, b, c) = map(int, input().split())
	(j, k) = (ceil(a / c), b // c)
	print([c * (k + 1), c][j > 1])


t = int(input())
while t > 0:
	li = input().split()
	l = int(li[0])
	r = int(li[1])
	d = int(li[2])
	if d < l or d > r:
		print(d)
	else:
		print(r // d * d + d)
	t -= 1


n = int(input())
for i in range(n):
	(l, r, d) = map(int, input().split())
	ld = (l + d - 1) // d
	rd = r // d
	if ld > 1:
		print(d)
	else:
		print((rd + 1) * d)


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	if r % d == 0:
		num = r + d
	else:
		num = (r // d + 1) * d
	if d < l:
		num = min(num, d)
	print(num)


q = int(input())
for I in range(q):
	(l, r, d) = map(int, input().split())
	(l1, r1) = (min(l, r), max(l, r))
	if d < l1:
		print(d)
	else:
		print((r1 // d + 1) * d)


for _ in range(int(input())):
	(l, r, d) = [int(_) for _ in input().strip().split()]
	if d < l:
		print(d)
	else:
		print(r + d - (r + d) % d)


from sys import stdin
n = int(stdin.readline().strip())
for i in range(n):
	s = list(map(int, stdin.readline().strip().split()))
	if s[0] > s[2]:
		print(s[2])
		continue
	x = s[1] // s[2]
	x += 1
	print(x * s[2])


tc = int(input())
for _ in range(tc):
	(l, r, d) = map(int, input().split(' '))
	ans = d
	if ans >= l:
		mod = r % d
		ans = r + (d - mod)
	print(ans)


import math
for i in range(int(input())):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	elif r / d == r // d:
		print((r // d + 1) * d)
	else:
		print(math.ceil(r / d) * d)


q = int(input())
for _ in range(q):
	(l, r, d) = list(map(int, input().split()))
	if d < l:
		print(d)
	else:
		v = d * (r // d)
		while v <= r:
			v += d
		print(v)


n = int(input())
while n != 0:
	n = n - 1
	str_len = input()
	l = int(str_len.split(' ')[0])
	r = int(str_len.split(' ')[1])
	d = int(str_len.split(' ')[2])
	if d not in range(l, r + 1):
		print(d)
	else:
		print(int(int(r / d + 1) * d))


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	d2 = d
	if d >= l and d <= r:
		d = d + r - (d + r) % d
	print(d)


n = int(input())
for i in range(0, n):
	(l, r, d) = map(int, input().split())
	ans = 0
	if l > d:
		ans = d
	else:
		ans = (r // d + 1) * d
	print(ans)


for t in range(int(input())):
	(l, r, d) = map(int, input().split(' '))
	x = l // d
	y = r // d
	if l % d == 0:
		x = x - 1
	if x > 0:
		print(d)
	else:
		print((y + 1) * d)


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().rstrip().split())
	if l <= d:
		x = r // d * d + d
		print(x)
	else:
		print(d)


q = int(input())
for _ in range(q):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
		continue
	dt = d * ((r - d) // d)
	while dt > r:
		dt -= d
	while dt <= r:
		dt += d
	print(dt)


a = int(input())
for i in range(a):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	elif r % d == 0:
		print(r + d)
	else:
		p = int(r / d)
		print(p * d + d)


num_queries = int(input())
for i in range(num_queries):
	(l, r, d) = list(map(int, input().split()))
	print(d if d < l else d * (1 + r // d))


n = input()
n = int(n)
for i in range(0, n):
	(l, r, d) = input().split(' ')
	(l, r, d) = (int(l), int(r), int(d))
	if d < l or d > r:
		print(d)
	else:
		k = r // d
		print((k + 1) * d)


def read():
	return int(input())

def reads():
	return [int(x) for x in input().split()]
N = int(input())
table = []
for i in range(N):
	(l, r, d) = reads()
	table.append((l, r, d))
for (l, r, d) in table:
	if d < l:
		print(d)
	else:
		print((r // d + 1) * d)


def f(ll):
	(l, r, d) = ll
	if l > d:
		return d
	return (r // d + 1) * d
t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	print(f(l))


N = int(input())
for q in range(N):
	(l, r, d) = map(int, input().split())
	if d < l:
		answer = d
	else:
		answer = (r // d + 1) * d
	print(answer)


import math
x = int(input())
for i in range(x):
	(n1, n2, n3) = map(int, input().split())
	i = 2
	if n3 < n1 and n3 < n2 or (n3 > n1 and n3 > n2):
		print(n3)
	if n3 == n2:
		print(2 * n3)
	if n3 >= n1 and n3 < n2:
		print(math.ceil((n2 + 1) / n3) * n3)


t = int(input())
for i in range(t):
	(l, r, d) = map(int, input().split())
	bottom = l / d
	if bottom > 1:
		print(d)
	else:
		top = r // d * d + d
		print(top)


t = int(input())
while t > 0:
	t = t - 1
	(l, r, d) = map(int, input().split())
	if l > d:
		print(d)
	else:
		print((r // d + 1) * d)


import math
q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	n = l / d
	if n > 1:
		print(d)
	else:
		n = r / d
		print((math.floor(n) + 1) * d)


def spdvd(a, b):
	if a % b == 0:
		return a / b - 1
	return a / b
q = int(input())
for i in range(q):
	(l, r, x) = list(map(int, input().split()))
	a = x * int(spdvd(l, x))
	b = x * (int(r / x) + 1)
	if a > x:
		print(x)
	elif min(a, b) > 0:
		print(min(a, b))
	else:
		print(max(a, b))


q = int(input())
for i in range(q):
	numbers = input().split()
	li = int(numbers[0])
	ri = int(numbers[1])
	di = int(numbers[2])
	if li != di and li / di >= 1:
		print(di)
	else:
		k = int(ri / di)
		print((k + 1) * di)


num = int(input())
x = 0
for i in range(num):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		x = r
		x += d - r % d
		print(x)


import math
sa = lambda : input()
sb = lambda : int(input())
sc = lambda : input().split()
sd = lambda : list(map(int, input().split()))
se = lambda : float(input())
sf = lambda : list(input())

def hnbhai():
	(l, r, d) = sd()
	temp = d
	while temp >= l and temp <= r:
		temp += d
		if temp >= l and temp <= r:
			temp = (r // d + 1) * d
			break
	print(temp)
for _ in range(sb()):
	hnbhai()


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	x = d
	if x < l or x > r:
		print(x)
		continue
	t = r // d + 1
	x = d * t
	print(x)


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return len(set(factors))

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))
MOD = 10 ** 9 + 7
T = 1
T = int(stdin.readline())
for _ in range(T):
	(l, r, d) = list(map(int, stdin.readline().split()))
	if d < l:
		print(d)
		continue
	rx = r // d + 1
	if l % d == 0:
		lx = l // d - 1
	else:
		lx = l // d
	if lx != 0:
		print(lx * d)
	else:
		print(rx * d)


q = int(input())
for _ in range(q):
	(l, r, d) = map(int, input().split())
	if d != 1:
		if d < l:
			print(d)
		else:
			x = d * (r // d + 1)
			y = d * (l // d)
			if y > 0 and y != l:
				print(y)
			else:
				print(x)
	elif d == 1:
		if l >= 2:
			print(1)
		else:
			print(r + 1)


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	if d == 1 and l == 1:
		print(r + 1)
	elif l == 1 and d < 1000:
		slag = 1
		while (r + slag) % d != 0:
			slag += 1
		print(r + slag)
	elif d <= 100 and d >= l:
		slag = 1
		while (r + slag) % d != 0:
			slag += 1
		print(slag + r)
	else:
		base = 1
		while l <= d * base <= r:
			base += 1
		print(base * d)


import math
q = int(input())
q1 = list(range(q))
for i in range(0, q):
	temp = map(int, input().split(' '))
	(l, r, d) = temp
	k = d
	if k >= l and k <= r:
		for j in range(0, math.ceil(r / l)):
			t1 = r % k
			k = r + k - t1
			if k > r:
				break
	q1[i] = k
for i in range(0, q):
	print(q1[i])


def task():
	p = input().split()
	l = int(p[0])
	u = int(p[1])
	d = int(p[2])
	if d < l or d > u:
		print(d)
	else:
		print(d * (1 + u // d))
t = int(input())
i = 0
while i < t:
	task()
	i += 1


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	print(((r // d + 1) * d, d)[d < l])


n = int(input())
for q in range(n):
	(l, r, d) = map(int, input().strip().split())
	if d * 1 < l:
		print(d)
	else:
		r += 1
		if r % d == 0:
			print(r)
			continue
		r -= r % d
		r += d
		print(r)


tt = int(input())
while tt:
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	elif d > r:
		print(d)
	else:
		print(int((r // d + 1) * d))
	tt -= 1


for i in range(int(input())):
	(l, r, d) = [int(x) for x in input().split()]
	print(d if d < l else r - r % d + d)


q = int(input())
while q > 0:
	(l, r, d) = map(int, input().split())
	a = l / d
	b = r / d
	min = 0
	if a > 1:
		min = d
	else:
		min = (int(b) + 1) * d
	print(min)
	q -= 1


q = int(input())
search_number = 0
for number_string in range(q):
	string = input()
	string_ = string.split()
	l = int(string_[0])
	r = int(string_[1])
	d = int(string_[2])
	if l / d > 1:
		search_number = d
	elif l // d <= 1:
		search_number = d * (r // d + 1)
	print(search_number)


for i in range(int(input())):
	a = [int(a) for a in input().split()]
	j = 1
	if a[2] < a[0] or a[2] > a[1]:
		print(a[2])
	else:
		print(a[1] // a[2] * a[2] + a[2])


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	if l / d <= 1:
		n = 0
	else:
		n = 1
	m = r // d + 1
	if n == 0:
		x = d * m
	else:
		x = d * n
	print(x)


import sys
import bisect
input = sys.stdin.readline
t = int(input())
mod = 10 ** 9 + 7
for _ in range(t):
	(l, r, d) = map(int, input().split())
	if l > d:
		print(1 * d)
	else:
		x = r // d
		print((x + 1) * d)


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict, deque, Counter, OrderedDict
import threading

def main():
	for _ in range(int(input())):
		(l, r, d) = map(int, input().split())
		if d < l:
			print(d)
		else:
			print((r // d + 1) * d)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
for _ in range(n):
	(l, r, d) = map(int, input().split())
	print(d if d < l else r + (d - r % d))


n = int(input())
for _ in range(n):
	(l, r, d) = [int(x) for x in input().split()]
	ans = d
	if l <= ans <= r:
		ans = (r + d - 1) // d * d
		if ans == r:
			ans += d
	print(ans)


for tc in range(int(input())):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		print((r // d + 1) * d)


import math

def get_min(l, r, d):
	cur = d
	if l <= cur <= r:
		cur = r // d * d + d
	return cur
n = int(input())
for i in range(n):
	(l, r, d) = list(map(int, input().split()))
	print(get_min(l, r, d))


for _ in range(int(input())):
	(l, r, c) = [*map(int, input().split())]
	count = c
	if c < l:
		print(c)
	elif c > r:
		print(c)
	else:
		print(c * (r // c + 1))


from math import ceil, floor, gcd
from collections import deque as queue

def decToBin(number, size=64):
	return bin(number)[2:].zfill(size)

def lcm(a, b):
	return a * b // gcd(a, b)

def binarySearch(arr, l, r, x):
	if r >= l:
		mid = l + (r - l) / 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binarySearch(arr, l, mid - 1, x)
		else:
			return binarySearch(arr, mid + 1, r, x)
	else:
		return -1
q = int(input())
for _ in range(q):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		x = r // d
		x += 1
		x *= d
		print(x)


t = int(input())
from math import *
for _ in range(t):
	(l, r, k) = map(int, input().split(' '))
	ans = 0
	a = int(floor(l / k))
	if l % k == 0:
		a -= 1
	ans = a * k
	if ans == 0:
		a = int(ceil(r / k))
		if r % k == 0:
			a += 1
		print(a * k)
	else:
		print(k)


from sys import stdin
t = int(stdin.readline())
for i in range(t):
	(l, r, d) = map(int, stdin.readline().split())
	if d < l:
		print(d)
	else:
		print(d * (r // d + 1))


def minint(n, a):
	for i in range(n):
		l = a[i][0]
		r = a[i][1]
		d = a[i][2]
		if l <= d <= r:
			print((r // d + 1) * d)
		else:
			print(d)
n = int(input())
v = []
for i in range(n):
	a = input().strip().split()
	a = list(map(int, a))
	v.append(a)
minint(n, v)


x = int(input())
for i in range(0, x):
	s = ''
	s1 = input().split()
	l = int(s1[0])
	r = int(s1[1])
	y = int(s1[2])
	if y < l:
		print(str(y))
	else:
		x = -1 * r % y
		if x == 0:
			x = y
		print(str(r + x))


nb_test = int(input())
for _ in range(nb_test):
	(l, r, d) = [int(x) for x in input().split()]
	if d < l:
		print(d)
	else:
		print((r // d + 1) * d)


n = int(input())
for _ in range(n):
	(l, r, d) = map(int, input().split())
	flag = False
	if d < l:
		print(d)
		continue
	if d > r:
		print(d)
		continue
	print(r // d * d + d)


import sys
q = int(sys.stdin.readline().strip())
for i in range(0, q):
	x = list(map(int, sys.stdin.readline().strip().split()))
	if x[2] < x[0] or x[0] > x[1]:
		print(x[2])
	else:
		print(x[1] // x[2] * x[2] + x[2])


n = int(input())
for x in range(n):
	(l, r, d) = map(int, input().split())
	q = l // d
	q1 = r // d
	if q > 0:
		if q == 1 and l % d == 0:
			pass
		else:
			if d < l:
				print(d)
			else:
				print(q * d)
			continue
	print((q1 + 1) * d)


from sys import stdin, stdout
input = stdin.readline
print = stdout.write
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
for _ in range(int(input())):
	(l, r, d) = mapin()
	if d < l:
		print(str(d) + '\n')
	else:
		print(str(r + d - r % d) + '\n')


from math import ceil
n = int(input())
for _ in range(n):
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		print(d)
	else:
		print(d * int(ceil((r + 1) / d)))


n = int(input())
for i in range(n):
	s = input().split(' ')
	if int(s[2]) < int(s[0]):
		print(int(s[2]))
	else:
		print(int(s[2]) * (int(s[1]) // int(s[2]) + 1))


for _ in range(int(input())):
	(l, r, d) = [int(i) for i in input().split()]
	if d < l:
		print(d)
	elif r % d == 0:
		print(r + d)
	else:
		print((r // d + 1) * d)


q = int(input())
for i in range(q):
	(j, w, d) = map(int, input().split())
	if d < j or d > w:
		www = d
	else:
		www = (w // d + 1) * d
	print(www)


t = int(input())
while t:
	(a, b, c) = map(int, input().split())
	if c < a:
		print(c)
	else:
		print(b + (c - b % c))
	t -= 1


entrada1 = int(input())
entrada2 = []
listaX = []
q = entrada1
for i in range(entrada1):
	entrada2.append(input().split())

def calcular_x(ele, r, d):
	x = 0
	if d < ele:
		x = d
	else:
		x = int(r / d) * d + d
	return x
for i in range(q):
	listaX.append(calcular_x(int(entrada2[i][0]), int(entrada2[i][1]), int(entrada2[i][2])))
for elemento in listaX:
	print(elemento)


t = int(input())
i = 0
while i < t:
	(n, p, d) = input().split()
	n = int(n)
	p = int(p)
	d = int(d)
	if n > d:
		print(d)
		i = i + 1
		continue
	r = p // d
	print(d * (r + 1))
	i = i + 1


q = int(input())
x = []
for i in range(q):
	(l, r, d) = input().split()
	l = int(l)
	r = int(r)
	d = int(d)
	if r - l < 0:
		t = l
		l = r
		r = t
	if r < d or d < l:
		x.append(d)
	else:
		x.append(d * (int(r / d) + 1))
for i in x:
	print(i)


for _ in range(int(input())):
	(l, r, d) = list(map(int, input().strip().split()))
	x = d
	if d < l:
		print(x)
		continue
	print((r // d + 1) * d)


def main():
	a = []
	for _ in range(int(input())):
		a.append(list(map(int, input().split())))
	for q in a:
		l = q[0]
		r = q[1]
		d = q[2]
		if d < l:
			print(d)
		else:
			print(d * (int(r / d) + 1))
main()


def rI():
	return [int(i) for i in input().split()]
q = rI()[0]
for i in range(q):
	(l, r, d) = rI()
	if d < l or d > r:
		print(d)
		continue
	oo = r // d
	print((oo + 1) * d)


for _ in range(int(input())):
	(l, r, d) = map(int, input().strip().split()[:3])
	if d not in range(l, r + 1):
		print(d)
	else:
		if l % d == 0:
			k = l - d
			if k <= 0:
				if r % d == 0:
					k = r + d
				else:
					k = r + (d - r % d)
		else:
			k = l - l % d
			if k <= 0:
				if r % d == 0:
					k = r + d
				else:
					k = r + (d - r % d)
		print(k)


q = int(input())
for i in range(0, q):
	inp = input()
	(l, r, d) = map(int, inp.split())
	if d < l:
		print(d)
		continue
	ans = (r // d + 1) * d
	print(ans)


x = int(input())
l = []
for i in range(x):
	l.append(list(map(int, input().split())))
for i in l:
	if (i[0] - 1) / i[2] >= 1:
		print(i[2])
	elif (i[1] + 1) / i[2] <= 1:
		print(i[2])
	else:
		print((i[1] // i[2] + 1) * i[2])


query = int(input())
for q in range(query):
	(l, r, d) = map(int, input().split())
	ans = 1
	if d < l or d > r:
		print(d)
	else:
		print((r // d + 1) * d)


x = int(input())
for i in range(x):
	(a, b, c) = [int(i) for i in input().split()]
	z = c
	if z < a:
		print(z)
	else:
		y = c - b % c
		z = b + y
		print(z)


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	x = y = 0
	if l > d:
		x = d
		print(x)
	else:
		if r % d == 0:
			y = r + d
		else:
			y = r // d * d
			y += d
		print(y)


t = int(input())
for _ in range(t):
	(p, q, r) = list(map(int, input().split()))
	if r < p:
		print(r)
	else:
		print((q // r + 1) * r)


n = int(input())
for i in range(n):
	(l, r, m) = map(int, input().split())
	if l > m:
		print(m)
	else:
		print((r // m + 1) * m)


import math

def minInt(l, r, d):
	if d < l:
		return d
	elif r % d == 0:
		return r + d
	else:
		return math.ceil(r / d) * d

def main():
	n = int(input())
	res = []
	for _ in range(n):
		res.append(minInt(*list(map(int, input().split()))))
	for out in res:
		print(out)
main()


r = range(int(input()))
for _ in r:
	(l, r, d) = list(map(int, input().split()))
	result = None
	for i in range(d, l, d):
		if i % d == 0:
			result = i
			break
	if not result:
		rr = r % d
		result = r + (d - rr)
		if result == r:
			result += d
	print(result)


n = int(input())
ans = []
for i in range(n):
	ans.append(list(map(int, input().split())))
for i in ans:
	ans1 = i[-1]
	if ans1 >= i[0] and ans1 <= i[1]:
		bagh = i[1] % ans1
		print(ans1 - bagh + i[1])
	else:
		print(ans1)


R = lambda : map(int, input().split())
q = int(input())
while q > 0:
	q = q - 1
	(l, r, d) = R()
	if d < l:
		print(d)
	elif d > r:
		print(d)
	else:
		print(d * (r // d + 1))


for u in range(int(input())):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	elif d >= l and d <= r:
		print((r // d + 1) * d)
	elif d > r:
		print(d)


from sys import stdin
q = int(stdin.readline())
for i in range(q):
	R = lambda : map(int, stdin.readline().split())
	(l, r, d) = R()
	small = (l - 1) // d
	large = r // d
	if small * d < l and small * d > 0:
		print(d)
	else:
		print((large + 1) * d)


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(t,) = I()
while t:
	t -= 1
	(l, r, d) = I()
	if l <= d <= r:
		if r % d == 0:
			print(r + d)
		else:
			print(r - r % d + d)
	else:
		print(d)


t = int(input())
while t:
	l = list(map(int, input().split()))
	(a, b, d) = (l[0], l[1], l[2])
	if d < a:
		print(d)
	else:
		r = b % d
		n = d - r
		num = b + n
		print(num)
	t -= 1


for _ in range(int(input())):
	s = [int(n) for n in input().split()]
	l = s[0]
	r = s[1]
	d = s[2]
	p = 0
	if l > d:
		print(d)
		p = 1
	if p == 0:
		j = r // d + 1
		print(j * d)


for _ in [0] * int(input()):
	(l, r, d) = map(int, input().split())
	print((d >= l) * r // d * d + d)


q = int(input())
for i in range(0, q):
	s = input()
	left = int(s.split(' ')[0])
	right = int(s.split(' ')[1])
	d = int(s.split(' ')[2])
	div = 1
	if d * div in range(left, right + 1):
		div = int(right / d) + 1
	print(d * div)


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


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	x1 = d
	x2 = (r // d + 1) * d
	if x1 < l:
		print(x1)
	else:
		print(x2)


import math
import sys
import itertools

def sa(Type=int):
	return [Type(x) for x in input().split()]

def solve(t):
	(l, r, d) = sa()
	x = d
	if l <= d <= r:
		p = r // d + 1
		print(p * d)
	else:
		print(d)
t = int(input())
for i in range(t):
	solve(i + 1)


q = int(input())
for i in range(q):
	(l, r, d) = input().split()
	l = int(l)
	r = int(r)
	d = int(d)
	if d < l or d > r:
		print(d)
	else:
		print((r // d + 1) * d)


q = int(input())
a = []
for i in range(q):
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		a.append(d)
	else:
		r += 1
		if r % d == 0:
			a.append(r)
		else:
			n = r + (d - r % d)
			a.append(n)
for i in a:
	print(i)


q = int(input())
res = ''
for _ in range(q):
	mult = 1
	(l, r, d) = [int(i) for i in input().split()]
	if d < l:
		new = d
		res += str(new) + '\n'
	else:
		res += str(d * (r // d + 1)) + '\n'
print(res)


q = int(input())
for i in range(q):
	inputs = input().split()
	l = int(inputs[0])
	r = int(inputs[1])
	d = int(inputs[2])
	if l > d:
		print(d)
	else:
		x = r // d
		print(d * (x + 1))


n = int(input())

def func(a, b, d):
	if a > d:
		return d
	elif b % d == 0:
		return b + d
	else:
		return b // d * d + d
for i in range(n):
	s = input().split()
	print(func(int(s[0]), int(s[1]), int(s[2])))


from math import ceil
x = int(input())
for i in range(x):
	(a, b, c) = map(int, input().split())
	if a > c:
		print(c)
	elif ceil(b / c) > b // c:
		print(c * ceil(b / c))
	else:
		print(c * (b // c + 1))


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	if l <= d and d <= r:
		x = r - r % d
		print(x + d)
	else:
		print(d)


q = int(input())
for j in range(q):
	(l, r, d) = map(int, input().split(' '))
	if d < l:
		print(d)
	else:
		print((r // d + 1) * d)


def f(l, r, d):
	if d > r:
		return d
	for i in range(d, l, d):
		if i % d == 0:
			return i
	return (int(r / d) + 1) * d
n = int(input())
for i in range(n):
	row = input().split(' ')
	l = int(row[0])
	r = int(row[1])
	d = int(row[2])
	print(str(int(f(l, r, d))))


import math
n = int(input())
for i in range(n):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		b = math.ceil(r / d)
		if r % d == 0:
			b += 1
		print(int(b * d))


import math
n = int(input())
while n:
	(l, r, d) = list(map(int, input().split(' ')))
	k1 = math.floor(r / d) + 1
	k2 = math.ceil(l / d) - 1
	if d == 1 and l == 1:
		print(1 + r)
	elif d < l:
		print(d)
	elif k2 != 0:
		print(k2 * d)
	else:
		print(k1 * d)
	n = n - 1


import sys
q = int(input())
for (l, r, d) in (map(int, l.split()) for l in sys.stdin):
	if l > d:
		print(d)
	else:
		ans = (r + d - 1) // d * d
		print(ans if ans != r else ans + d)


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		x = d
	elif d < r:
		resto = r % d
		x = d + (r - resto)
	else:
		x = d + d
	print(x)


q = int(input())
ar = []
for i in range(q):
	lrd = input().split()
	l = int(lrd[0])
	r = int(lrd[1])
	d = int(lrd[2])
	if d < l:
		valor = d
	elif (r + 1) % d == 0:
		valor = r + 1
	else:
		valor = d * ((r + 1) // d + 1)
	ar.append(valor)
print('\n'.join(map(str, ar)))


from math import ceil
for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	elif d > r:
		print(d)
	elif r % d == 0:
		print((ceil(r / d) + 1) * d)
	else:
		print(ceil(r / d) * d)


def minimal(a, b, c):
	if c < a or c > b:
		return c
	else:
		return b // c * c + c
q = int(input())
for _ in range(q):
	(l, r, d) = map(int, input().split())
	print(minimal(l, r, d))


def min_numb(lst):
	a = list()
	for elem in lst:
		if elem[2] < elem[0] or elem[2] > elem[1]:
			a.append(elem[2])
		else:
			a.append(elem[1] // elem[2] * elem[2] + elem[2])
	return a
q = int(input())
b = list()
for i in range(q):
	(l, r, d) = [int(j) for j in input().split()]
	b.append([l, r, d])
for x in min_numb(b):
	print(x)


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	if l > d:
		print(d)
	elif d >= l and d <= r:
		x = r % d
		x1 = d - x
		n = r + x1
		print(n)
	else:
		print(d)


import random

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
q = ii()
while q > 0:
	(l, r, d) = tuple(mi())
	if l // d == 1:
		if d * (l // d) < l:
			print(d * (l // d))
			q -= 1
			continue
	elif l // d > 1:
		print(d)
		q -= 1
		continue
	if d * (r // d) <= r:
		print(d * (r // d + 1))
	else:
		print(d * (r // d))
	q = q - 1


for i in range(int(input())):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		k = (r + d - 1) // d
		ans = k * d
		if ans == r:
			ans += d
		print(ans)


a = int(input())
i = 0
while i in range(a):
	(b, c, d) = map(int, input().split())
	s = c % d
	if s == 0 and (b < d or b == d):
		print(c + d)
	elif s != 0 and (b < d or b == d):
		print(c + d - s)
	elif s == 0 and b > d:
		print(d)
	elif s != 0 and b > d:
		print(d)
	i += 1


import sys
input = sys.stdin.buffer.readline
import os
from math import *
t = int(input())
while t:
	t -= 1
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	elif r % d == 0:
		print(r + d)
	else:
		print(r + d - r % d)


def main():
	t = int(input())
	for __ in range(t):
		(l, r, d) = map(int, input().split())
		if l // d >= 1 and l != d:
			print(d)
		else:
			print((r // d + 1) * d)
main()


q = int(input())
for j in range(q):
	(l, r, d) = map(int, input().split())
	ans = []
	if d == 1:
		if l - d > 0:
			ans.append(l - d)
		ans.append(r + d)
	if l % d == 0:
		if l - d > 0:
			ans.append(l - d)
	if r % d == 0:
		ans.append(r + d)
	if l % d:
		if l - l % d > 0:
			ans.append(l - l % d)
	if r % d:
		ans.append(r + d - r % d)
	if d < l:
		ans.append(d)
	print(min(ans))


def solve(l, r, d):
	if l // d > 1:
		return d
	elif l // d == 1 and l != d:
		return d
	else:
		return (r // d + 1) * d
t = int(input())
for _ in range(t):
	(l, r, d) = map(int, input().split())
	print(solve(l, r, d))


q = int(input())
for i in range(q):
	(l, r, d) = [int(z) for z in input().split()]
	x = d
	if l <= x <= r:
		x = r + 1
		xmd = x % d
		x += d - xmd if xmd else 0
	print(x)


import math
mod = 1000000007
t = int(input())
for _ in range(t):
	(l, r, d) = [int(i) for i in input().split()]
	if l > d:
		q = l // d
		re = l % d
		x = l - re - (q - 1) * d
	else:
		re = r % d
		x = r + d - re
	print(x)


q = int(input())
for i in range(q):
	lrd = input().split()
	for j in range(3):
		lrd[j] = int(lrd[j])
	l = lrd[0]
	r = lrd[1]
	d = lrd[2]
	if d < l:
		print(d)
	else:
		print(d * (r // d + 1))


import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		print(r // d * d + d)


a = int(input())
for i in range(a):
	(b, c, d) = map(int, input().split())
	if d >= min(b, c):
		print(max(b, c) + (d - max(b, c) % d))
	else:
		print(d)


t = int(input())
for i in range(t):
	s = input()
	s = s.split(' ')
	for j in range(3):
		s[j] = int(s[j])
	l = s[0]
	r = s[1]
	d = s[2]
	if d >= l and d <= r:
		x = r // d
		result = (x + 1) * d
		print(result)
	else:
		print(d)


n = int(input())
for i in range(n):
	x = list(map(int, input().split(' ')))
	a = x[0]
	b = x[1]
	c = x[2]
	if c < a or c > b:
		print(c)
	else:
		i = b // c
		while True:
			if i * c > b:
				print(i * c)
				break
			else:
				i += 1


q = int(input())
while q > 0:
	(l, r, d) = [int(x) for x in input().split()]
	if d > l and d > r or (d < l and d < r):
		print(d)
	elif r % d == 0:
		print(r + d)
	else:
		print(r // d * d + d)
	q -= 1


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb
from fractions import Fraction as fr

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
q = int(input())
while q:
	q -= 1
	(l, r, d) = map(int, input().split())
	r1 = l // d
	r2 = r // d
	if r1 > 1 or (r1 == 1 and l % d):
		print(d)
	else:
		print((r2 + 1) * d)


try:
	q = int(input())
	for i in range(q):
		(l, r, d) = map(int, input().split())
		if d < l or d > r:
			print(d)
		else:
			print(r // d * d + d)
except:
	pass


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if c < a or c > b:
		print(c)
	else:
		z = b // c + 1
		print(c * z)


for x in range(int(input())):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
		continue
	print(d * (int(r / d) + 1))


for i in range(int(input())):
	(left, right, d) = map(int, input().split())
	print(d if left > d else (right // d + 1) * d)


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	i = d
	if l <= i <= r:
		mul = r // i
		i = i * (mul + 1)
	print(i)


for i in range(int(input())):
	(l, r, d) = map(int, input().split())
	j = r + 1
	if d < l:
		print(d)
	else:
		c = r // d
		print(int(d * (c + 1)))


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if c < a or c > b:
		print(c)
	else:
		d = b // c
		print(c * (d + 1))


n = int(input())
for i in range(n):
	l = [int(i) for i in input().split()]
	if l[2] < l[0] or l[2] > l[1]:
		print(l[2])
	else:
		print((int(l[1] // l[2]) + 1) * l[2])


tests = int(input())
ans = [None] * tests
for i in range(tests):
	(x, y, z) = map(int, input().split())
	if z < x or z > y:
		ans[i] = z
	else:
		ans[i] = y // z * z + z
for sol in ans:
	print(sol)


def ceil(a, b):
	if a % b:
		return a // b + 1
	else:
		return a // b
n = int(input())
for i in range(n):
	(l, r, d) = map(int, input().split())
	if l > d:
		print(d)
	else:
		print((r // d + 1) * d)


import math
n = int(input())
for i in range(n):
	x = list(map(int, input().split()))
	l = x[0]
	r = x[1]
	d = x[2]
	if d < l:
		print(d)
	else:
		print(r + d - r % d)


def element(queries):
	l = int(queries[0])
	r = int(queries[1])
	d = int(queries[2])
	if d < l or d > r:
		return d
	else:
		return (r // d + 1) * d
size = int(input())
for i in range(size):
	queries = input().split()
	elem = str(element(queries))
	print(elem)


n = int(input())
for i in range(n):
	l = input()
	l1 = l.split()
	n1 = int(l1[0])
	n2 = int(l1[1])
	n3 = int(l1[2])
	while True:
		if n3 < n1 or n3 > n2:
			break
		else:
			n3 *= int(n2 / n3) + 1
	print(n3)


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	if l > d:
		print(d)
	elif r % d == 0:
		print(r + d)
	else:
		print(r // d * d + d)


n = int(input())
for i in range(n):
	(l, r, d) = map(int, input().split())
	flag = False
	if not l <= d <= r:
		print(d)
	else:
		print((r // d + 1) * d)


q = int(input())
for i in range(q):
	(li, ri, di) = input().split()
	li = int(li)
	ri = int(ri)
	di = int(di)
	minimun = li // di
	maximun = ri // di
	if ri % di == 0 or di < ri:
		maximun = ri // di + 1
	if di < li or di > ri:
		print(di)
	else:
		print(di * maximun)


import math
t = int(input())
for i in range(t):
	(l, r, d) = map(int, input().strip().split(' '))
	k = d
	while True:
		if k % d == 0 and (k < l or k > r):
			print(k)
			break
		else:
			j = r - k
			m = math.ceil(j / d)
			k = (m + 1) * d
		if k == r:
			print(k + d)
			break


q = int(input())
M = [list(map(int, input().split())) for i in range(q)]
S = []
l = len(S)
for i in range(q):
	x = 1
	while True:
		if x < M[i][0] or x > M[i][1]:
			if x % M[i][2] == 0:
				S.append(x)
				break
			elif x < M[i][2]:
				x = M[i][2]
			else:
				x = x + (M[i][2] - x % M[i][2])
		elif M[i][2] >= M[i][0]:
			x = M[i][1] + 1
		elif M[i][2] < M[i][0]:
			x = 2
for i in S:
	print(i)


N = int(input())
for i in range(N):
	(a, b, c) = map(int, input().split())
	if c < a:
		print(c)
	else:
		b = b + c - b % c
		print(b)


q = int(input())
while q:
	(l, r, d) = map(int, input().split())
	if l > d or d > r:
		print(d)
	else:
		print(r // d * d + d)
	q = q - 1


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	ans = []
	for _ in range(n):
		(a, b, c) = LI()
		x = a / c
		if 1 < x:
			ans.append(c)
		else:
			y = b // c * c
			if b < y:
				ans.append(y)
			else:
				ans.append(y + c)
	for x in ans:
		print(x)
main()


gi = lambda : list(map(int, input().split()))
for k in range(gi()[0]):
	(l, r, d) = gi()
	if l <= d <= r:
		ans = r // d * d
		if r % d or r // d * d == r:
			ans += d
	else:
		ans = d
	print(ans)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a > c:
		print(c)
	else:
		r = b % c
		r = c - r
		print(b + r)


t = int(input())
for kk in range(t):
	(l, r, d) = map(int, input().split())
	if l > d or r < d:
		print(d)
	else:
		print(int((r + d) / d) * d)


n = int(input())
for i in range(n):
	z = 0
	p = 0
	ls = [int(i) for i in input().split()]
	x = min(ls[0], ls[1])
	y = max(ls[0], ls[1])
	if ls[2] < x:
		print(ls[2])
	else:
		q = y // ls[2]
		print(ls[2] * (q + 1))


import math
n = int(input())
for i in range(n):
	s = input()
	(l, r, d) = [int(x) for x in s.split()]
	if l / d > 1:
		print(d)
	else:
		print(d * (math.floor(r / d) + 1))


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


n_queries = int(input())
queries = [[int(i) for i in input().split()] for x in range(n_queries)]

def parse(query):
	(l, r, d) = query
	if d < l:
		return d
	return (r // d + 1) * d
for query in queries:
	print(parse(query))


q = int(input())
for w in range(q):
	(l, r, d) = [int(x) for x in input().split()]
	res = d
	if d < l or d > r:
		print(d)
	else:
		res = (max(r // d, 1) + 1) * d
		print(res)


n = int(input())
m = 0
for i in range(n):
	f = True
	x = list(map(int, input().split()))
	m = x[2]
	if m < x[0] or m > x[1]:
		print(m)
	else:
		print(x[1] - x[1] % m + m)


q = int(input())
for _ in range(q):
	(l, r, d) = map(int, input().split())
	q1 = l // d
	if q1 > 0:
		if l % d == 0:
			if q1 > 1:
				print(d)
			else:
				q2 = r // d
				print((q2 + 1) * d)
		else:
			print(d)
	else:
		q2 = r // d
		print((q2 + 1) * d)


x = int(input())

def my_function(x, y, z):
	returnable = z
	if z < x or z > y:
		return returnable
	else:
		returnable = y - y % z
		return returnable + z
while x > 0:
	x -= 1
	querie = list(map(int, input().split()))
	print(my_function(querie[0], querie[1], querie[2]))


def minInteger(l, r, d):
	if l > d or r < d:
		print(d)
	else:
		print((r // d + 1) * d)

def listMinInteger(q, N):
	for i in N:
		minInteger(i[0], i[1], i[2])
q = int(input())
N = [list(map(int, input().split())) for _ in range(q)]
listMinInteger(q, N)


t = int(input())
L = []
R = []
D = []
for i in range(t):
	(l, r, d) = map(int, input().split())
	L.append(l)
	R.append(r)
	D.append(d)
for i in range(t):
	small = L[i] / D[i]
	large = R[i] / D[i]
	if small > 1.0:
		print(D[i])
	else:
		print((int(large) + 1) * D[i])


n = int(input())
for i in range(n):
	(l, r, d) = map(int, input().strip().split(' '))
	if d < l or d > r:
		print(d)
	else:
		k = d - r % d
		ans = r + k
		print(ans)


q = int(input())
for i in range(q):
	entrada = list(map(int, input().split()))
	if entrada[2] < entrada[0]:
		print(entrada[2])
	else:
		saida = entrada[1] // entrada[2] + 1
		print(saida * entrada[2])


n = int(input())
lista = []
for i in range(n):
	(l, r, d) = input().split()
	(l, r, d) = (int(l), int(r), int(d))
	h = d
	if d < l or d > r:
		lista.append(d)
	elif r == d:
		lista.append(d * 2)
	else:
		lista.append((r // d + 1) * d)
for i in lista:
	print(i)


import math
i = input
n = int(i())
f = False
for j in range(n):
	(l, r, d) = map(int, i().split())
	if d not in range(l, r + 1):
		print(d)
	elif r % d == 0:
		print((r // d + 1) * d)
	else:
		print(math.ceil(r / d) * d)


from sys import stdin

def read_lines(sep=' ', input_type=None):
	_lines = stdin.readlines()
	cast = input_type is not None
	lines = []
	for line in _lines:
		line = line[:-1].split(sep)
		if cast:
			line = [input_type(x) for x in line]
		lines.append(line)
	return lines

def sequential_max_diff(seq):
	unlagged_seq = seq[:-1]
	lagged_seq = seq[1:]
	maxd = 0
	for pair in zip(unlagged_seq, lagged_seq):
		diff = abs(pair[0] - pair[1])
		if diff > maxd:
			maxd = diff
	return maxd

def main2():
	lines = read_lines(input_type=int)
	n = lines[0][0]
	heights = lines[1]
	_seq = heights
	_seq.sort()
	least = _seq[-1]
	elements = _seq
	min_pair = None
	for i in range(len(elements)):
		for j in range(len(elements)):
			if j == i:
				continue
			(a, b) = (elements[i], elements[j])
			seq = _seq.copy()
			seq.remove(a)
			seq.remove(b)
			res = max(sequential_max_diff([a] + seq + [b]), abs(a - b))
			if res < least:
				min_pair = (a, b)
				least = res
	seq = _seq.copy()
	seq.remove(min_pair[0])
	seq.remove(min_pair[1])
	out = list(map(str, [min_pair[0]] + seq + [min_pair[1]]))
	print(' '.join(out))

def main3():
	lines = read_lines(input_type=int)
	(n, m, k) = lines[0]
	v = lines[1]
	max1 = max(v)
	max2 = 0
	max_appears = 0
	for ele in v:
		if ele == max1:
			max_appears += 1
			if max_appears == 2:
				print(max1 * m)
				return
	for ele in v:
		if ele != max1:
			if ele >= max2:
				max2 = ele
	block_size = k + 1
	num_of_blocks = m // block_size
	remainder = m % block_size
	value = num_of_blocks * (k * max1 + max2) + remainder * max1
	print(value)

def main4():
	lines = read_lines(input_type=int)
	n = lines[0][0]
	if n % 4 == 0:
		print(0)
	elif n % 4 == 2:
		print(1)
	elif n % 4 == 1:
		print(1)
	else:
		print(0)

def main():
	lines = read_lines(input_type=int)
	for line in lines[1:]:
		(l, r, d) = line
		if d > r:
			print(d)
		elif d == r:
			print(2 * d)
		elif d < l:
			print(d)
		else:
			print(d * (r // d + 1))
main()


for i in [0] * int(input()):
	(l, r, d) = map(int, input().split())
	print((d >= l) * (r // d) * d + d)


N = int(input())
X = list()
for i in range(N):
	X.append(list(map(int, input().split())))
i = 0
while i < N:
	INTEGER = X[i][2]
	if INTEGER >= X[i][0] and INTEGER <= X[i][1]:
		INTEGER = X[i][1] + (X[i][2] - X[i][1] % X[i][2] if X[i][1] % X[i][2] != 0 else X[i][2])
	print(INTEGER)
	i += 1


def g(r, d):
	c = (r + d) % d
	return r + d - c

def solve(l, r, d):
	if d < l:
		return d
	else:
		return g(r, d)

def main():
	n = int(input())
	for i in range(n):
		(l, r, d) = map(int, input().split())
		answer = solve(l, r, d)
		print(answer)
main()


r = []
for _ in range(int(input())):
	(a, b, c) = list(map(int, input().split()))
	if c >= a:
		r.append(b + c - b % c)
	else:
		r.append(c)
for i in r:
	print(i)


j = int(input())
for i in range(j):
	arr = [int(x) for x in input().split()]
	if arr[2] < arr[0] or arr[2] > arr[1]:
		print(arr[2])
	elif arr[2] >= arr[0] and arr[2] <= arr[1]:
		temp = arr[1] - arr[2]
		if (temp // arr[2] + 2) * arr[2] != arr[1]:
			print(arr[2] * (temp // arr[2] + 2))
		else:
			print(arr[2] * (temp // arr[2] + 3))


import sys
q = int(input())
for i in range(q):
	(l, r, d) = map(int, sys.stdin.readline().split())
	ans = 0
	if l > d:
		ans = d
	else:
		ans = r + d - r % d
	print(ans)


q = int(input())
answers = []
for i in range(q):
	(l, r, d) = input().split()
	(l, r, d) = (int(l), int(r), int(d))
	if d < l:
		answers.append(d)
		continue
	else:
		s = r // d * d + d
		if s <= r:
			s += d
		answers.append(s)
for i in answers:
	print(i)


import math
for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	f = math.ceil(l / d) * d
	s = math.floor(r / d) * d
	if l > d:
		print(d)
	else:
		print(s + d)


a = int(input())
for i in range(a):
	(q, w, e) = map(int, input().split())
	if e < q:
		print(e)
	else:
		print((w // e + 1) * e)


n = int(input())
m = [tuple(map(int, input().split())) for _ in range(n)]
for i in m:
	a = i[0] - i[0] % i[2]
	if a > i[2] or a <= 0:
		a = i[2]
	b = i[1] + i[2] - i[1] % i[2]
	if a < i[0]:
		print(a)
		continue
	else:
		print(b)


def main():
	q = int(input())
	for t in range(q):
		(l, r, d) = input().split()
		l = int(l)
		r = int(r)
		d = int(d)
		if d > r or d < l:
			print(d)
		else:
			print(r + d - r % d)
main()


import sys

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = sys.stdin.readline().split()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_int(self):
		return int(self.next())

	def solve(self):
		n = self.next_int()
		for i in range(0, n):
			l = self.next_int()
			r = self.next_int()
			d = self.next_int()
			if d < l:
				print(d)
			else:
				print(r // d * d + d)
Main().solve()


import math as ma
import sys
from sys import exit
from decimal import Decimal as dec
from itertools import permutations

def li():
	return list(map(int, input().split()))

def num():
	return map(int, input().split())

def nu():
	return int(input())
mm = 1000000007
t = nu()
for it in range(t):
	(l, r, d) = num()
	a = (l - 1) % d
	b = r % d
	z = l - 1 - a
	v = d - b + r
	if d < l:
		print(d)
	else:
		print(v)


q = int(input())
res = []
for a in range(q):
	(l, r, d) = map(int, input().split())
	k = l // d
	q = r // d + 1
	a = 1
	for a in range(1, k + 1):
		x = d * a
		if l <= x <= r:
			continue
		else:
			res.append(x)
			a = 0
			break
	if a:
		for a in range(q, 2 * 10 ** 9):
			x = d * a
			if l <= x <= r:
				continue
			else:
				res.append(x)
				break
for a in res:
	print(a)


q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		print(d)
	else:
		a = r - r % d + d
		print(a)


q = int(input())
s = 0
for i in range(0, q):
	e = list(map(int, input().split()))
	s = e[2]
	if s >= e[0] and s <= e[1]:
		print(s + e[1] - e[1] % s)
	else:
		print(s)


n = int(input())
for i in range(n):
	(l, r, d) = map(int, input().split())
	x = d
	if x < l:
		print(x)
	if x > r:
		print(x)
	if x >= l and x <= r:
		k = r // x
		x = x * (k + 1)
		print(x)


n = int(input())
(l, r, d) = ([], [], [])
for i in range(n):
	(li, ri, di) = map(int, input().split())
	l.append(li)
	r.append(ri)
	d.append(di)
for i in range(n):
	ans = 0
	if l[i] / d[i] > 1:
		ans = d[i]
	else:
		temp = r[i] // d[i] + 1
		ans = temp * d[i]
	print(ans)


def f(x):
	(l, r, d) = map(int, x.split())
	if l > d:
		return d
	else:
		return r + (d - r % d)
q = int(input())
print('\n'.join(map(str, [f(input()) for _ in range(q)])))


q = int(input())

def f(l, r, d):
	if d < l or d > r:
		return d
	return d * (int(r / d) + 1)
for k in range(q):
	(l, r, d) = map(int, input().split())
	print(f(l, r, d))


from math import *
n = int(input())
p = 0
while p < n:
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	if c < a:
		print(c)
	elif c >= a:
		k = b // c
		print((k + 1) * c)
	p += 1


n = int(input())
for _ in range(n):
	a = list(map(int, input().split()))
	l = a[0]
	r = a[1]
	d = a[2]
	if l <= d and d <= r:
		print((r // d + 1) * d)
	else:
		print(d)


import math
q = int(input())
l = [None] * q
r = [None] * q
d = [None] * q
for x in range(q):
	(l[x], r[x], d[x]) = [int(y) for y in input().split()]
for x in range(q):
	if d[x] < l[x]:
		print(d[x])
	else:
		res = int(r[x] / d[x]) + 1
		print(res * d[x])


t = int(input())
while t > 0:
	t -= 1
	(l, r, d) = map(int, input().split())
	i = 1
	low = l // d
	high = r // d
	if low == 0 or low * d == l == 1 * d:
		print((high + 1) * d)
	else:
		print(d)


Q = int(input())
for q in range(Q):
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		print(d)
	else:
		x = r // d
		print((x + 1) * d)


import math
import os
import random
import re
import sys
t = int(input())
for i in range(0, t):
	a = list(map(int, input().rstrip().split()))
	(l, r, d) = (a[0], a[1], a[2])
	if d < l:
		print(d)
	else:
		k = r // d
		t = d * (k + 1)
		print(t)


q = int(input())
for i in range(q):
	a = 0
	(l, r, d) = map(int, input().split())
	while True:
		a += d
		if d < l:
			a = d
			break
		if l <= a <= r:
			a = (r // d + 1) * d
		if a % d == 0:
			break
	print(a)


n = int(input())
while n > 0:
	(a, b, d) = input().split(' ')
	a = int(a)
	b = int(b)
	d = int(d)
	lst = range(a, b + 1)
	if d not in lst:
		print(d)
	else:
		q = b % d
		print(b + d - q)
	n -= 1


import math
from decimal import *
import random
for _ in range(int(input())):
	(left, right, d) = map(int, input().split())
	if d == 1 and left > 1:
		print(1)
	elif d == 1 and left == 1:
		print(right + 1)
	elif left <= d * 1:
		print(math.ceil((right + 1) / d) * d)
	else:
		print(d)


from collections import defaultdict, deque
from heapq import heappush, heappop
from math import inf
ri = lambda : map(int, input().split())

def solve():
	(l, r, d) = ri()
	if d < l:
		print(d)
		return
	print(r + (d - r % d))
t = 1
t = int(input())
while t:
	t -= 1
	solve()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	aa = [LI() for _ in range(n)]
	rr = []
	for (l, r, d) in aa:
		if d < l:
			rr.append(d)
		else:
			rr.append(r - r % d + d)
	return '\n'.join(map(str, rr))
print(main())


q = int(input())
for i in range(q):
	firstlastnum = list(map(int, input().split()))
	first = firstlastnum[0]
	last = firstlastnum[1]
	num = firstlastnum[2]
	div2 = last // num
	if num < first:
		print(num)
	else:
		print(div2 * num + num)


n = int(input())
res = []
while n:
	(l, r, d) = map(int, input().split())
	if d < l:
		res.append(d)
	elif d > r:
		res.append(d)
	elif l <= d <= r:
		m = r % d
		if m == 0:
			res.append(r + d)
		else:
			res.append(d * (r // d + 1))
	n = n - 1
for i in res:
	print(i)


t = int(input())
while t:
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	elif d >= l:
		a = int(r / d) + 1
		print(a * d)
	t -= 1


for C in range(int(input())):
	(a, b, c) = map(int, input().split())
	d = c * (b // c)
	if c < a:
		print(c)
		continue
	else:
		while d <= b:
			d += c
		print(d)


import math

def A():
	q = int(input())
	for i in range(q):
		(l, r, d) = map(int, input().split())
		if d < l:
			print(d)
			continue
		if not r % d:
			print((r // d + 1) * d)
			continue
		print(math.ceil(r / d) * d)
A()


queries = int(input())
minimums_x = []
for q in range(queries):
	(l, r, d) = list(map(int, input().split()))
	if d < l or d > r:
		minimums_x.append(d)
		continue
	elif r % d != 0:
		minimums_x.append(int(r / d) * d + d)
	else:
		minimums_x.append(r + d)
for num in minimums_x:
	print(num)


a = int(input())
k = []
for i in range(a):
	(b, c, d) = list(map(int, input().split()))
	if d < b:
		k.append(d)
	else:
		k.append((c // d + 1) * d)
for i in range(a):
	print(k[i])


n = int(input())
for i in range(n):
	s = input()
	s = s.strip()
	y = s.find(' ')
	l = int(s[:y])
	r = int(s[y + 1:s.rfind(' ')])
	d = int(s[s.rfind(' ') + 1:])
	if d < l:
		print(d)
	else:
		x = r // d
		k = (x + 1) * d
		print(k)


user_i = input()
q = int(user_i)
for i in range(q):
	user_i = input()
	(l, r, d) = user_i.split(' ')
	l = int(l)
	r = int(r)
	d = int(d)
	if d < l:
		print(d)
	else:
		print(int(r / d) * d + d)


for _ in [0] * int(input()):
	(p, q, r) = map(int, input().split())
	print((r >= p) * q // r * r + r)


import math
for _ in range(int(input())):
	(l, r, x) = map(int, input().split())
	if l > x:
		print(x)
	else:
		print(x * (math.floor(r / x) + 1))


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
for _ in range(int(z())):
	(a, b, c) = map(int, z().split())
	if c < a or c > b:
		print(c)
		continue
	print(b + (c - b % c))


q = int(input())

def solve(l, r, d):
	if l > d:
		return d
	elif r % d == 0:
		return r + d
	else:
		return d * (r // d + 1)
for _ in range(q):
	[l, r, d] = list(map(int, input().split()))
	print(solve(l, r, d))


from math import ceil
q = int(input())
for i in range(q):
	(l, r, d) = list(map(int, input().split()))
	x = d
	y = (r // d + 1) * d
	s = min(x, y)
	if s >= l:
		print(max(x, y))
	else:
		print(s)


q = int(input())
for q in range(0, q):
	k = [int(a) for a in input().split()]
	l = k[0]
	r = k[1]
	d = k[2]
	if d < l or d > r:
		x = d
	else:
		x = r - r % d + d
	print(x)


q = int(input())
for x in range(q):
	(l, r, d) = list(map(int, input().split()))
	a = l / d
	b = r / d
	if a > 1:
		print(d)
	else:
		print((int(b) + 1) * d)


q = int(input())
for i in range(q):
	(a, r, m) = map(int, input().split())
	k = 2
	d = m
	if d < a:
		print(d)
	elif d > r:
		print(d)
	else:
		print(d * (r // d + 1))


q = int(input())
for i in range(q):
	(l, r, x) = map(int, input().split())
	rr = r % x
	if l > x:
		print(x)
	else:
		rr = x - rr
		print(r + rr)


amount = int(input())
for i in range(amount):
	(left, right, num) = [int(s) for s in input().split()]
	if num < left:
		print(num)
	else:
		print(right + (num - right % num))


n = int(input())
for _ in range(n):
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		k = r % d == 0 and d or d - r % d
		print(r + k)


t = int(input())
q = []
for i in range(t):
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		q.append(str(d))
	else:
		q.append(str((r // d + 1) * d))
print('\n'.join(q))


for x1 in range(int(input())):
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		print(d)
	else:
		print((int(r / d) + 1) * d)


import math
q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	s = l / d
	if d < l:
		print(d)
	elif d >= l and d <= r:
		if d * math.ceil(r // d) <= r:
			print(d * math.ceil(r // d) + d)
		else:
			print(d * math.ceil(r // d))
	else:
		print(d)


n = int(input())
for k in range(n):
	(a, b, c) = map(int, input().split())
	print((b // c * c + c, c)[c < a])


for _ in range(int(input())):
	(a, b, d) = map(int, input().split())
	m1 = a % d
	m2 = b % d
	if m1 != 0 and a // d != 0:
		print(d)
	elif m1 == 0 and a // d >= 2:
		print(d)
	else:
		print(d * (b // d + 1))


def solve(l, r, d):
	if d < l:
		return d
	elif l - l % d > 0 and l % d != 0:
		return l - l % d
	else:
		return (int(r / d) + 1) * d
x = int(input())
while x > 0:
	[l, r, d] = list(map(int, input().split()))
	print(solve(l, r, d))
	x -= 1


n = int(input())
for i in range(n):
	(m, n, k) = [int(x) for x in input().split()]
	if k < m or k > n:
		print(k)
	else:
		print(k * (n // k + 1))


import sys

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	print(d if d < l else r - r % d + d)


def ans(arr):
	(l, r, d) = (arr[0], arr[1], arr[2])
	x1 = l / d
	x2 = r / d
	if x1 > 1:
		return d
	return d * (int(x2) + 1)
t = int(input())
for _ in range(t):
	n = list(map(int, input().strip().split()))
	print(ans(n))


rd = lambda : list(map(int, input().split()))
for _ in range(rd()[0]):
	(l, r, d) = rd()
	print(d if not l <= d <= r else r // d * d + d)


test_cases = int(input())
for i in range(test_cases):
	(left, right, divisor) = map(int, input().split(' '))
	if divisor < left:
		print(divisor)
	else:
		print(divisor * (right // divisor + 1))


import sys
input = sys.stdin.readline
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
	if a[i][0] <= a[i][2] and a[i][2] <= a[i][1]:
		print((a[i][1] // a[i][2] + 1) * a[i][2])
	else:
		print(a[i][2])


x = int(input())
for i in range(x):
	i = input().split()
	if int(i[2]) < int(i[0]):
		print(int(i[2]))
	else:
		print(int(i[2]) + int(i[2]) * (int(i[1]) // int(i[2])))


t = int(input())
for z in range(t):
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		print(d)
	else:
		x = r % d
		sid = r - x + d
		print(sid)


import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10, log2
from itertools import permutations
from heapq import heappush, heappop, heapify
inf = float('inf')
mod = 1000000007

def factorial_p(n, p):
	ans = 1
	if n <= p // 2:
		for i in range(1, n + 1):
			ans = ans * i % p
	else:
		for i in range(1, p - n):
			ans = ans * i % p
		ans = pow(ans, p - 2, p)
		if n % 2 == 0:
			ans = p - ans
	return ans

def nCr_p(n, r, p):
	ans = 1
	while n != 0 or r != 0:
		(a, b) = (n % p, r % p)
		if a < b:
			return 0
		ans = ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p) % p
		n //= p
		r //= p
	return ans

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
for i in range(n):
	(l, r, d) = get_ints()
	if d < l or d > r:
		print(d)
	else:
		print(ceil((r + 1) / d) * d)


q = int(input())
l = []
r = []
d = []
for i in range(q):
	(x, y, z) = [int(a) for a in input().split()]
	l.append(x)
	r.append(y)
	d.append(z)

def FindMinPos(l, r, d, q):
	resTab = []
	for i in range(q):
		if d[i] >= l[i] and d[i] <= r[i]:
			remain = r[i] % d[i]
			if remain == 0:
				res = r[i] + d[i]
			else:
				res = r[i] + (d[i] - remain)
		else:
			res = d[i]
		resTab.append(res)
	for x in resTab:
		print(x)
FindMinPos(l, r, d, q)


import math
n = int(input())
mtrx = [list((int(x) for x in input().split())) for i in range(n)]
for i in range(n):
	if mtrx[i][2] < mtrx[i][0]:
		print(mtrx[i][2])
	if mtrx[i][2] >= mtrx[i][0]:
		print(math.ceil((mtrx[i][1] + 1) / mtrx[i][2]) * mtrx[i][2])


n = int(input())
for i in range(n):
	(s, e, d) = [int(j) for j in input().split()]
	if s > d:
		print(d)
	elif e % d == 0:
		print(e + d)
	else:
		print((e // d + 1) * d)


from sys import stdin, stdout
q = int(stdin.readline())
for i in range(q):
	[l, r, d] = [int(x) for x in stdin.readline().split()]
	cof = d
	while True:
		if d > 0 and d < l or d > r:
			stdout.write(str(d) + '\n')
			break
		else:
			stdout.write(str(d * (r // d + 1)) + '\n')
			break


import math
import os
import random
import re
import sys
from collections import Counter
a = []
l = []
n = int(input())
for i in range(n):
	l += [list(map(int, input().split()))]
for i in range(n):
	if l[i][2] <= l[i][1] and l[i][2] >= l[i][0]:
		print(l[i][2] * (l[i][1] // l[i][2] + 1))
	else:
		print(l[i][2])


for _ in range(int(input())):
	(L, R, D) = map(int, input().split())
	print(D + (0, R - R % D)[L <= D <= R])


def solve(l, r, d):
	if d < l:
		return d
	return d * (r // d + 1)
q = int(input())
for i in range(q):
	(l, r, d) = map(int, input().split())
	print(solve(l, r, d))


def number_list():
	return list(map(int, input().split()))

def arr2d(rows, cols, v=0):
	return [[v for i in range(cols)] for _ in range(rows)]
t = int(input())
for tt in range(t):
	(l, r, d) = number_list()
	ans = 0
	if d < l or d > r:
		ans = d
	else:
		res = max(r, d) % min(r, d)
		if res == 0:
			ans = d + r
		else:
			ans = r + (d - r % d)
	print(ans)


n = int(input())
for i in range(n):
	(l, r, d) = map(lambda x: int(x), input().split())
	dl = (l - 1) // d
	dr = r // d + 1
	print(dl < 1 and dr * d or d)


count = int(input())
mas = []
for i in range(count):
	s = input().split(' ')
	l = int(s[0])
	r = int(s[1])
	d = int(s[2])
	if d < l:
		mas.append(d)
	else:
		j = r / d
		if j % 1 == 0:
			j = (j + 1) * d
		else:
			j = (j - j % 1 + 1) * d
		mas.append(j)
	print(int(mas[-1]))


def solution(entrada):
	x = entrada[2]
	jump = False
	while x % entrada[2] != 0 or (x >= entrada[0] and x <= entrada[1]):
		if (x >= entrada[0] and x <= entrada[1]) and jump == False:
			x += int((entrada[1] - entrada[0]) / entrada[2]) * entrada[2]
			jump = True
		else:
			x += entrada[2]
	print(x)
n_entradas = int(input())
entradas = []
for i in range(n_entradas):
	entradas.append(list(map(int, input().split(' '))))
for entrada in entradas:
	solution(entrada)


n = int(input())
for i in range(n):
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		print(d)
	else:
		print(2 * d + (r - d) // d * d)


n = int(input())
for i in range(n):
	a = list(map(int, input().split()))
	count = 1
	if a[2] < a[0] or a[2] > a[1]:
		print(a[2])
	else:
		print((int(a[1] / a[2]) + 1) * a[2])


q = int(input())

def check_left(l, r, d):
	return d

def check_right(l, r, d):
	result = 0
	if r % d == 0:
		result = r + d
	else:
		result = r - r % d + d
	return result

def minimum_integer(l, r, d):
	if l - d <= 0:
		return check_right(l, r, d)
	else:
		return check_left(l, r, d)
for i in range(q):
	(l, r, d) = [int(e) for e in input().split()]
	print(minimum_integer(l, r, d))


for k in range(int(input())):
	(l, r, d) = map(int, input().split())
	if d == 1:
		if l == 1:
			print(r + 1)
		else:
			print(1)
	elif l >= d:
		if l % d == 0:
			if l // d > 1:
				print(d)
			else:
				print((r // d + 1) * d)
		else:
			print(d)
	else:
		print((r // d + 1) * d)


import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
ARR = lambda : list(map(int, input().split()))

def printARR(arr):
	for e in arr:
		print(e, end=' ')
	print()

def main():
	(l, r, d) = M()
	if d < l:
		print(d)
	else:
		ans = r + (d - r % d)
		print(ans)
tc = 1
tc = I()
for _ in range(tc):
	main()


t = int(input())
while t > 0:
	(l, r, d) = map(int, input().split())
	x = d
	if x < l or x > r:
		print(x)
	elif r % d == 0:
		print((r // d + 1) * d)
	else:
		a = r % d
		b = (r // d + 1) * d
		print(b)
	t = t - 1


n = int(input())
entradas = []
saida = []
for i in range(n):
	entradas.append(input())
for j in entradas:
	entrada = j.split()
	achou = False
	k = 1
	while not achou:
		num = int(entrada[2]) * k
		if num < int(entrada[0]) or num > int(entrada[1]):
			achou = True
			saida.append(num)
		elif num < int(entrada[0]):
			k += 1
		elif num < int(entrada[1]):
			k += int(int(entrada[1]) / int(entrada[2]))
		else:
			k += 1
for l in saida:
	print(int(l))


import time
n = int(input(''))
l = []
r = []
d = []
for i in range(n):
	(a, b, c) = input('').split()
	l.append(int(a))
	r.append(int(b))
	d.append(int(c))
for i in range(n):
	if l[i] / d[i] > 1:
		print(d[i])
	else:
		print((r[i] // d[i] + 1) * d[i])


for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	(l, r) = (min(l, r), max(l, r))
	if d < l or d > r:
		print(d)
	else:
		print(r + d - r % d)


import math
q = int(input())
for tt in range(q):
	(l, r, d) = map(int, input().split())
	if d == 1:
		if l > 1:
			print(1)
		else:
			print(r + 1)
		continue
	if d > r:
		print(d)
		continue
	if d < l:
		print(d)
		continue
	if l > d:
		xx = r // d
		print(xx * d)
		continue
	yy = math.floor(l / d)
	xx = math.ceil(r / d)
	lx = yy * d
	rx = xx * d
	if lx == l:
		lx = (yy - 1) * d
	if rx == r:
		rx = (xx + 1) * d
	if lx <= 0:
		lx = 1000000000000
	print(min(lx, rx))


class Solution(object):

	def solve(self):
		n = int(input().strip())
		rtr = []
		for i in range(n):
			(l, r, d) = map(int, input().strip().split(' '))
			if d > r or d < l:
				rtr.append(d)
			elif d >= l:
				_add = int(r // d + 1)
				rtr.append(d * _add)
			else:
				_add = l % d
				if _add == 0:
					_add = d
				if l - _add > 0:
					rtr.append(l - _add)
				else:
					_add = int(r // d + 1)
					rtr.append(d * _add)
		return rtr
sol = Solution()
for x in sol.solve():
	print(x)


q = int(input())
for _ in range(q):
	(l, r, d) = map(int, input().split())
	left = 0
	right = 0
	if d == 1:
		if l == 1:
			print(r + 1)
		else:
			print(1)
	else:
		if l % d == 0:
			left += 1
		if r % d == 0:
			right += 1
		if l // d - left > 0:
			print(d)
		else:
			print(r - r % d + d)


n = int(input())
for q in range(n):
	(j, k, l) = list(map(int, input().split()))
	if j > l:
		print(l)
	else:
		d = k // l
		s = l * d
		while s < k:
			s += l
		if s == k:
			s += l
		print(s)


q = int(input())
for I in range(q):
	(l, r, d) = [int(i) for i in input().split()]
	if d < l:
		print(d)
	else:
		mul = (r // d + 1) * d
		print(mul)


a = int(input())
for i in range(0, a):
	flag = 0
	b = list(map(int, input().split()))
	if b[0] // b[2] >= 1:
		if b[0] % b[2] == 0 and b[0] // b[2] == 1:
			flag = 0
		else:
			m = b[2]
			flag = 1
	if flag == 0:
		if b[1] % b[2] == 0:
			m = b[1] + b[2]
		else:
			m = b[1] + b[2] - b[1] % b[2]
	print(m)


def find(l, r, d):
	if d < l:
		return d
	elif d > r:
		return d
	else:
		return (r // d + 1) * d
t = int(input())
lst = []
for i in range(0, t):
	(l, r, d) = input().split()
	ele = find(int(l), int(r), int(d))
	lst.append(ele)
for i in range(0, t):
	print(lst[i])


t = int(input())
while t > 0:
	t = t - 1
	(l, r, d) = map(int, input().split())
	intial = (l - 1) // d
	if intial >= 1:
		print(d)
	elif (r + 1) % d != 0:
		final = (r + 1) // d
		print(d * (final + 1))
	else:
		print(r + 1)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(L, R, D) = getInts()
	if L > D:
		return D
	if R < D:
		return D
	x = R % D
	R += D - x
	return R
for _ in range(getInt()):
	print(solve())


q = int(input())
for asgafsdhheresfaddfg in range(q):
	(a, b, c) = map(int, input().split())
	ans1 = c
	ans2 = (b + 1) // c * c
	if ans2 <= b:
		ans2 = ((b + 1) // c + 1) * c
	if ans1 < a:
		print(ans1)
	else:
		print(ans2)


for _ in range(int(input())):
	(n, m, d) = map(int, input().split())
	if n / d > 1:
		print(d)
	else:
		print(d * (m // d + 1))


n = int(input())
for i in range(n):
	(l, r, d) = map(int, input().split())
	if r < 0:
		print(d)
		continue
	elif l > d:
		print(d)
		continue
	elif r % d == 0:
		print(r + d)
		continue
	else:
		print(r // d * d + d)
		continue


test = int(input())
for i in range(test):
	ans = 0
	(l, r, d) = input().split()
	[l, r, d] = [int(l), int(r), int(d)]
	if l <= d:
		if r % d == 0:
			ans = r + d
		else:
			ans = r + d - r % d
	elif l > d:
		ans = d
	print(ans)


n = int(input(''))
for x in range(0, n):
	x = list(map(int, input().split()))
	if x[2] < x[0]:
		x[2] = x[2]
	elif x[2] > x[1]:
		x[2] = x[2]
	else:
		x[2] = x[2] * (x[1] // x[2] + 1)
	print(x[2])


q = int(input())
while q > 0:
	(l, r, d) = input().split(' ')
	l = int(l)
	r = int(r)
	d = int(d)
	if d < l:
		print(d)
	else:
		print((int(r / d) + 1) * d)
	q -= 1


T = int(input())
for t in range(T):
	(l, r, d) = [int(i) for i in input().split()]
	i = 0
	while d * (r // d + i) <= r:
		i += 1
	ans = d * (r // d + i)
	ans2 = d
	if ans2 < l:
		print(ans2)
	else:
		print(ans)


def main():
	q = int(input())
	for _ in range(q):
		[l, r, d] = [int(x) for x in input().split()]
		if l <= d <= r:
			print((r // d + 1) * d)
		else:
			print(d)
main()


for _ in [0] * int(input()):
	(l, r, v) = map(int, input().split())
	print((v >= l) * r // v * v + v)


from math import ceil

def slve(l, r, d):
	if (l - 1) // d >= 1:
		return d
	return ceil((r + 1) / d) * d
for _ in range(int(input())):
	(l, r, d) = map(int, input().split())
	print(slve(l, r, d))


test = int(input())
while test:
	test -= 1
	temp = list(map(int, input().split(' ')))
	l = temp[0]
	r = temp[1]
	d = temp[2]
	if d > r or d < l:
		print(d)
	else:
		t = r // d + 1
		print(d * t)


def func(l, r, d):
	if l <= d:
		print((r // d + 1) * d)
	else:
		print(d)

def main():
	count = int(input())
	for _ in range(count):
		arr = input().split()
		func(int(arr[0]), int(arr[1]), int(arr[2]))
main()


n = int(input())
for i in range(0, n):
	a = list(map(int, input().split()))
	if a[0] == a[2] or a[0] == 1:
		num = a[1] + 1
		if a[1] == a[2] and a[0] == a[1]:
			print(2 * a[1])
		elif a[1] == 1:
			print(a[2])
		elif a[2] % a[1] == 0:
			print(a[1] + a[2])
		else:
			while 1:
				if num % a[2] == 0:
					print(num)
					break
				num += 1
	else:
		num = a[2]
		while 1:
			if num not in range(a[0], a[1] + 1):
				print(num)
				break
			num += a[2]


numQuerys = int(input())
while numQuerys != 0:
	query = input().split()
	(num1, num2, num3) = (int(query[0]), int(query[1]), int(query[2]))
	if num1 > num3:
		print(num3)
	else:
		mod = num2 % num3
		print(num2 - mod + num3)
	numQuerys -= 1


n = int(input())
for _ in range(n):
	(l, r, d) = map(int, input().split())
	i = r // d
	j = l // d
	if j > 0 and l != d:
		print(d)
	else:
		print(d * i + d)


T = int(input())
for _ in range(T):
	(l, r, d) = (int(i) for i in input().split())
	if d < l:
		print(d)
	else:
		print(d * (r // d + 1))


n = int(input())
q = [[int(j) for j in input().split()] for i in range(n)]
for i in range(n):
	if q[i][2] < q[i][0]:
		print(q[i][2])
	else:
		print((q[i][1] // q[i][2] + 1) * q[i][2])


def main():
	q = int(input())
	for i in range(q):
		s = [int(x) for x in input().split()]
		l = s[0]
		r = s[1]
		d = s[2]
		if d < l or d > r:
			print(d)
		else:
			a = r // d
			print(d * (a + 1))
main()


q = int(input())
ii = 0
while ii < q:
	ii += 1
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	else:
		ans = r + 1
		if ans % d == 0:
			print(ans)
		else:
			ans += d - ans % d
			print(ans)


import sys
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def main():
	from math import log, ceil, floor
	for tc in range(int(input())):
		(l, r, d) = get_ints()
		if d < l:
			print(d)
		elif d >= l and d <= r:
			print(d * floor(r / d) + d)
		else:
			print(d)
main()


TN = int(input())

def solution():
	(l, r, d) = map(int, input().split())
	if d < l:
		print(d)
	elif d > r:
		print(d)
	elif l <= d <= r:
		print((r // d + 1) * d)
while TN != 0:
	solution()
	TN -= 1


q = int(input())
for i in range(q):
	(x, y, z) = map(int, input().split())
	if z > x and z > y:
		print(z)
	if z > x and z < y or z == x or z == y:
		f = y // z
		m = (f + 1) * z
		print(m)
	if z < x and z < y:
		print(z)


import math
q = int(input())
for _ in range(q):
	(l, r, d) = map(int, input().split())
	if d >= l:
		x = math.ceil(r / d) * d
		if x == r:
			x += d
	else:
		x = d
	print(x)


I = lambda : map(int, input().split())
for i in range(int(input())):
	(l, r, d) = I()
	if d < l or d > r:
		print(d)
	else:
		print(r // d * d + d)


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	(l, r, x) = invr()
	a = x
	b = r // x * x + x
	if a < l:
		print(a)
	else:
		print(b)


q = int(input())

def find_next(a, d):
	if a // d == a / d:
		return a + d
	else:
		x = a // d
		y = (x + 1) * d
		return y

def check(l, r, d):
	for i in range(d, l, d):
		if i % d == 0:
			return i
	index = find_next(r, d)
	return index
for i in range(q):
	(l, r, d) = map(int, input().strip().split())
	print(check(l, r, d))


rows = int(input())
for i in range(rows):
	nums = input().split()
	l = int(nums[0])
	r = int(nums[1])
	d = int(nums[2])
	if d < l:
		print(d)
		continue
	else:
		x = d
		if x <= r:
			x = r + d - r % d
		print(x)


t = int(input())
while t > 0:
	t -= 1
	s = input()
	s = s.split()
	l = int(s[0])
	r = int(s[1])
	d = int(s[2])
	if l > d:
		print(d)
	else:
		x = r // d + 1
		print(x * d)


import math
t = int(input())
while t > 0:
	(l, r, d) = map(int, input().split())
	if d < l or d > r:
		print(d)
	else:
		k = math.ceil(r / d)
		if d * k == r:
			print(d * (k + 1))
		else:
			print(d * k)
	t -= 1


from sys import stdin
q = int(stdin.readline().strip())
for _ in range(q):
	(l, r, d) = list(map(int, stdin.readline().split()))
	if l > d:
		print(d)
	else:
		temp = r // d
		print((temp + 1) * d)


n = int(input())
con = []
for i in range(n):
	nums = input().split(' ')
	con.append([int(nums[0]), int(nums[1]), int(nums[2])])
res = []
for i in con:
	if i[0] > i[2] or i[1] < i[2]:
		res.append(i[2])
	else:
		res.append((i[1] // i[2] + 1) * i[2])
for i in res:
	print(i)


for x in range(int(input())):
	arr = [int(i) for i in input().split()]
	n = 1
	if arr[2] >= arr[0] and arr[2] <= arr[1]:
		n = int(arr[1] / arr[2]) + 1
	print(n * arr[2])


ansarr = []
q = int(input())
for l in range(q):
	(l, r, d) = map(int, input().split())
	if l > d:
		ansarr.append(d)
	elif r % d == 0:
		ansarr.append(r + d)
	else:
		val = r // d
		ansarr.append((val + 1) * d)
print(*ansarr)


def func():
	temp = list(map(int, input().split()))
	(l, r, d) = (temp[0], temp[1], temp[2])
	temp = d
	if d < l or d > r:
		print(d)
		return
	else:
		print((r // d + 1) * d)
q = int(input())
for i in range(q):
	func()


t = int(input())
while t:
	(l, r, d) = map(int, input().split())
	if l > d:
		print(d)
	else:
		ans = r + d
		ans1 = ans // d
		print(ans1 * d)
	t = t - 1


q = int(input())
while q:
	q -= 1
	(l, r, d) = [int(x) for x in input().split()]
	if l > d:
		print(d)
	else:
		print((r // d + 1) * d)


n = int(input())
for _ in range(n):
	(l, r, d) = (int(s) for s in input().split(' '))
	if d < l:
		print(d)
	elif r % d == 0:
		print(r + d)
	else:
		print(r // d * d + d)


q = int(input())
listValors = []
for i in range(q):
	valor = input().split(' ')
	li = int(valor[0])
	ri = int(valor[1])
	di = int(valor[2])
	if li / di >= 1 and li != di:
		print(di)
	else:
		print((int(ri / di) + 1) * di)


def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
for _ in range(ii()):
	(a, b, d) = mi()
	if d > b or d < a:
		print(d)
	else:
		print((b // d + 1) * d)


N = int(input())
B = []
for i in range(0, N):
	(a, b, c) = map(int, input().split())
	if c < a or c > b:
		B.append(c)
	else:
		B.append((b // c + 1) * c)
for i in B:
	print(i)


from math import floor
q = int(input())
while q != 0:
	q -= 1
	(a, b, c) = map(int, input().split())
	if c < a:
		print(c)
	else:
		print(c * floor(b / c) + c)


q = int(input())
for i in range(q):
	x = list(map(int, input().split()))
	if x[2] < x[0]:
		print(x[2])
	else:
		y = x[1] // x[2] + 1
		print(y * x[2])


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10000000)

class Operation:

	def __init__(self, name, function, function_on_equal, neutral_value=0):
		self.name = name
		self.f = function
		self.f_on_equal = function_on_equal

def add_multiple(x, count):
	return x * count

def min_multiple(x, count):
	return x

def max_multiple(x, count):
	return x
sum_operation = Operation('sum', sum, add_multiple, 0)
min_operation = Operation('min', min, min_multiple, 1000000000.0)
max_operation = Operation('max', max, max_multiple, -1000000000.0)

class SegmentTree:

	def __init__(self, array, operations=[sum_operation, min_operation, max_operation]):
		self.array = array
		if type(operations) != list:
			raise TypeError('operations must be a list')
		self.operations = {}
		for op in operations:
			self.operations[op.name] = op
		self.root = SegmentTreeNode(0, len(array) - 1, self)

	def query(self, start, end, operation_name):
		if self.operations.get(operation_name) == None:
			raise Exception('This operation is not available')
		return self.root._query(start, end, self.operations[operation_name])

	def summary(self):
		return self.root.values

	def update(self, position, value):
		self.root._update(position, value)

	def update_range(self, start, end, value):
		self.root._update_range(start, end, value)

	def __repr__(self):
		return self.root.__repr__()

class SegmentTreeNode:

	def __init__(self, start, end, segment_tree):
		self.range = (start, end)
		self.parent_tree = segment_tree
		self.range_value = None
		self.values = {}
		self.left = None
		self.right = None
		if start == end:
			self._sync()
			return
		self.left = SegmentTreeNode(start, start + (end - start) // 2, segment_tree)
		self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end, segment_tree)
		self._sync()

	def _query(self, start, end, operation):
		if end < self.range[0] or start > self.range[1]:
			return None
		if start <= self.range[0] and self.range[1] <= end:
			return self.values[operation.name]
		self._push()
		left_res = self.left._query(start, end, operation) if self.left else None
		right_res = self.right._query(start, end, operation) if self.right else None
		if left_res is None:
			return right_res
		if right_res is None:
			return left_res
		return operation.f([left_res, right_res])

	def _update(self, position, value):
		if position < self.range[0] or position > self.range[1]:
			return
		if position == self.range[0] and self.range[1] == position:
			self.parent_tree.array[position] = value
			self._sync()
			return
		self._push()
		self.left._update(position, value)
		self.right._update(position, value)
		self._sync()

	def _update_range(self, start, end, value):
		if end < self.range[0] or start > self.range[1]:
			return
		if start <= self.range[0] and self.range[1] <= end:
			self.range_value = value
			self._sync()
			return
		self._push()
		self.left._update_range(start, end, value)
		self.right._update_range(start, end, value)
		self._sync()

	def _sync(self):
		if self.range[0] == self.range[1]:
			for op in self.parent_tree.operations.values():
				current_value = self.parent_tree.array[self.range[0]]
				if self.range_value is not None:
					current_value = self.range_value
				self.values[op.name] = op.f([current_value])
		else:
			for op in self.parent_tree.operations.values():
				result = op.f([self.left.values[op.name], self.right.values[op.name]])
				if self.range_value is not None:
					bound_length = self.range[1] - self.range[0] + 1
					result = op.f_on_equal(self.range_value, bound_length)
				self.values[op.name] = result

	def _push(self):
		if self.range_value is None:
			return
		if self.left:
			self.left.range_value = self.range_value
			self.right.range_value = self.range_value
			self.left._sync()
			self.right._sync()
			self.range_value = None

	def __repr__(self):
		ans = '({}, {}): {}\n'.format(self.range[0], self.range[1], self.values)
		if self.left:
			ans += self.left.__repr__()
		if self.right:
			ans += self.right.__repr__()
		return ans

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
TestCases = True
testingMode = False
optimiseForReccursion = False

def is_Valid(a, b):
	x = min(a, b)
	y = max(a, b)
	diff = y - x
	y = y - 2 * diff
	x = x - 1 * diff
	if x >= 0 and y >= 0 and (x % 3 == 0) and (y % 3 == 0):
		return True
	return False

def main():
	(l, r, d) = get_tuple()
	if d < l:
		print(d)
	else:
		print((r // d + 1) * d)
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


q = int(input())
x = []
for i in range(q):
	(li, ri, di) = map(int, input().split())
	if di < li:
		x.append(di)
	elif di > ri:
		x.append(di)
	else:
		x.append(di * (ri // di + 1))
for i in range(q):
	print(x[i])


import math
n = int(input())
for _ in range(n):
	(a, b, c) = input().split()
	c = int(c)
	x = int(a) / c
	y = int(b) / c
	x = math.ceil(x - 1)
	y = math.floor(y + 1)
	if x * c <= 0:
		print(y * c)
	elif x >= 1:
		print(1 * c)


n_consultas = int(input())
if 1 <= n_consultas <= 500:
	for i in range(n_consultas):
		(l, r, d) = input().split(' ')
		(l, r, d) = (int(l), int(r), int(d))
		if 1 <= l <= r <= 10 ** 9 and 1 <= d <= 10 ** 9:
			x = d
			if d < l:
				print(d)
			else:
				m = int(r / d)
				while True:
					x = d * m
					if x > r:
						print(x)
						break
					m += 1


n = int(input())
strk = []
result = 0
for i in range(n):
	k = input().split()
	for j in k:
		strk.append(int(j))
	if strk[2] < strk[0]:
		result = strk[2]
	if result == 0:
		if strk[0] <= strk[2] <= strk[1]:
			result = strk[2] * (strk[1] // strk[2] + 1)
	if result == 0:
		if strk[2] > strk[1]:
			result = strk[2]
	print(result)
	result = 0
	strk = []


n = int(input())
for i in range(n):
	(l, r, d) = [int(s) for s in input().split()]
	min_no = d
	if min_no < l or min_no > r:
		print(min_no)
	else:
		t = r // d + 1
		print(d * t)


from math import *
n = int(input())
if n <= 500:
	for i in range(n):
		l = [int(i) for i in input().split()]
		if (l[0] >= 1 and l[0] <= pow(10, 9)) and (l[1] >= 1 and l[1] <= pow(10, 9)) and (l[2] >= 1 and l[2] <= pow(10, 9)):
			j = 1
			s = 0
			while 1:
				if l[0] == 1:
					if l[1] < l[2]:
						s = l[2]
						break
					elif l[1] % l[2] == 0:
						s = l[1] + l[2]
						break
					elif l[1] % l[2] != 0:
						k = l[1] % l[2]
						s = l[1] + l[2] - k
						break
				elif l[0] <= l[2]:
					if l[1] < l[2]:
						s = l[2]
						break
					elif l[1] % l[2] == 0:
						s = l[1] + l[2]
						break
					elif l[1] % l[2] != 0:
						k = l[1] % l[2]
						s = l[1] + l[2] - k
						break
				else:
					s = l[2] * j
					if l[0] > s or s > l[1]:
						break
				j += 1
			print(s)


def minimum_integer(l, r, d):
	if d > r or d < l:
		return d
	else:
		d *= r // d + 1
		return d
q = int(input())
for e in range(q):
	(l, r, d) = map(int, input().split())
	print(minimum_integer(l, r, d))