You are on page 1of 1

A.

Minimum Integer
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given qq queries in the following form:

Given three integers lili, riri and didi, find minimum positive integer xixi such that it is divisible
by didi and it does not belong to the segment [li,ri][li,ri].

Can you answer all the queries?


Recall that a number xx belongs to segment [l,r][l,r] if l≤x≤rl≤x≤r.
Input
The first line contains one integer qq (1≤q≤5001≤q≤500) — the number of queries.
Then qq lines follow, each containing a query given in the
format lili riri didi (1≤li≤ri≤1091≤li≤ri≤109, 1≤di≤1091≤di≤109). lili, riri and didi are integers.
Output

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

You might also like