import math
def fin(f,g,h):
if h<f:
return h
elif h>=f and h<g:
if g%h !=0:
return d*(math.ceil(g/d))
else:
return d*(math.ceil(g/d)+1)
elif h==g:
return h*2
else:
return h
t= int(input())
for k in range(t):
l , r , d = map(int,input().split())
print(fin(l,r,d))
#include <iostream>
#include <algorithm>
#include <math.h>
//#include <vector>
//#include <stack>
//#include <queue>
//#include <map>
//#include <set>
//#include <deque>
#define ll long long
#define pp pop_back
#define sz size()
#define N 100005
#define ff first
#define ss second
#define pb push_back
using namespace std;
int t, n, d, l, r;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> t;
while ( t-- ) {
cin >> l >> r >> d;
if(l > d){
cout << d << '\n';
}
else {
cout << ((r/d)+1) * d << '\n';
}
}
}
1706C - Qpwoeirut And The City | 1697A - Parkway Walk |
1505B - DMCA | 478B - Random Teams |
1705C - Mark and His Unfinished Essay | 1401C - Mere Array |
1613B - Absent Remainder | 1536B - Prinzessin der Verurteilung |
1699B - Almost Ternary Matrix | 1545A - AquaMoon and Strange Sort |
538B - Quasi Binary | 424A - Squats |
1703A - YES or YES | 494A - Treasure |
48B - Land Lot | 835A - Key races |
1622C - Set or Decrease | 1682A - Palindromic Indices |
903C - Boxes Packing | 887A - Div 64 |
755B - PolandBall and Game | 808B - Average Sleep Time |
1515E - Phoenix and Computers | 1552B - Running for Gold |
994A - Fingerprints | 1221C - Perfect Team |
1709C - Recover an RBS | 378A - Playing with Dice |
248B - Chilly Willy | 1709B - Also Try Minecraft |