#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long l, r, k;
cin >> l >> r >> k;
// حالة خاصة إذا كان l == r
if (l == r) {
if (k >= 1) {
cout << 1 << endl;
} else {
cout << 0 << endl;
}
continue;
}
// حساب عدد العناصر في النطاق
long long rangeSize = r - l + 1;
// حساب العدد الأقصى للعمليات الممكنة
long long maxOperations = rangeSize / k;
// إضافة 1 إذا كان هناك باقي في القسمة
if (rangeSize % k != 0) {
maxOperations++;
}
cout << maxOperations << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgdDsKICAgIGNpbiA+PiB0OwoKICAgIHdoaWxlICh0LS0pIHsKICAgICAgICBsb25nIGxvbmcgbCwgciwgazsKICAgICAgICBjaW4gPj4gbCA+PiByID4+IGs7CgogICAgICAgIC8vINit2KfZhNipINiu2KfYtdipINil2LDYpyDZg9in2YYgbCA9PSByCiAgICAgICAgaWYgKGwgPT0gcikgewogICAgICAgICAgICBpZiAoayA+PSAxKSB7CiAgICAgICAgICAgICAgICBjb3V0IDw8IDEgPDwgZW5kbDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGNvdXQgPDwgMCA8PCBlbmRsOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KCiAgICAgICAgLy8g2K3Ys9in2Kgg2LnYr9ivINin2YTYudmG2KfYtdixINmB2Yog2KfZhNmG2LfYp9mCCiAgICAgICAgbG9uZyBsb25nIHJhbmdlU2l6ZSA9IHIgLSBsICsgMTsKCiAgICAgICAgLy8g2K3Ys9in2Kgg2KfZhNi52K/YryDYp9mE2KPZgti12Ykg2YTZhNi52YXZhNmK2KfYqiDYp9mE2YXZhdmD2YbYqQogICAgICAgIGxvbmcgbG9uZyBtYXhPcGVyYXRpb25zID0gcmFuZ2VTaXplIC8gazsKCiAgICAgICAgLy8g2KXYttin2YHYqSAxINil2LDYpyDZg9in2YYg2YfZhtin2YMg2KjYp9mC2Yog2YHZiiDYp9mE2YLYs9mF2KkKICAgICAgICBpZiAocmFuZ2VTaXplICUgayAhPSAwKSB7CiAgICAgICAgICAgIG1heE9wZXJhdGlvbnMrKzsKICAgICAgICB9CgogICAgICAgIGNvdXQgPDwgbWF4T3BlcmF0aW9ucyA8PCBlbmRsOwogICAgfQoKICAgIHJldHVybiAwOwp9