#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long l, r, k;
cin >> l >> r >> k;
if (l == r) {
if (k >= 1) {
cout << 1 << endl;
} else {
cout << 0 << endl;
}
} else {
long long count = (r - l + 1) / k;
cout << count << endl;
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgdDsKICAgIGNpbiA+PiB0OwogICAgCiAgICB3aGlsZSAodC0tKSB7CiAgICAgICAgbG9uZyBsb25nIGwsIHIsIGs7CiAgICAgICAgY2luID4+IGwgPj4gciA+PiBrOwoKICAgICAgICBpZiAobCA9PSByKSB7CiAgICAgICAgICAgIGlmIChrID49IDEpIHsKICAgICAgICAgICAgICAgIGNvdXQgPDwgMSA8PCBlbmRsOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgY291dCA8PCAwIDw8IGVuZGw7CiAgICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBsb25nIGxvbmcgY291bnQgPSAociAtIGwgKyAxKSAvIGs7CiAgICAgICAgICAgIGNvdXQgPDwgY291bnQgPDwgZW5kbDsKICAgICAgICB9CiAgICB9CiAgICAKICAgIHJldHVybiAwOwp9