#include <bits/stdc++.h>
using namespace std;
int main() {
int t,l,r,k,n,rm; cin >> t;
while(t--){
cin >> l >> r >> k;
if(k == 1){
cout << r-l+1 << endl;
continue;
}
n = (l+r)/k;
int cnt = 0,m_cnt = 0; //m_cnt : multiple count, rm : highest multiple of l in [l,r]
for(int i=l;i<=n;i++){
rm = (r/i)*i;
m_cnt = (rm-i)/i+1;
if(m_cnt >= k) cnt++;
else break;
}
cout << cnt << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWludCB0LGwscixrLG4scm07CWNpbiA+PiB0OwoJd2hpbGUodC0tKXsKCQljaW4gPj4gbCA+PiByID4+IGs7CgkJaWYoayA9PSAxKXsKCQkJY291dCA8PCByLWwrMSA8PCBlbmRsOwoJCQljb250aW51ZTsKCQl9CgkJCgkJbiA9IChsK3IpL2s7CgkJaW50IGNudCA9IDAsbV9jbnQgPSAwOyAvL21fY250IDogbXVsdGlwbGUgY291bnQsIHJtIDogaGlnaGVzdCBtdWx0aXBsZSBvZiBsIGluIFtsLHJdCgkJZm9yKGludCBpPWw7aTw9bjtpKyspewoJCQlybSA9IChyL2kpKmk7CgkJCW1fY250ID0gKHJtLWkpL2krMTsKCQkJaWYobV9jbnQgPj0gaykJY250Kys7CgkJCWVsc2UJYnJlYWs7CgkJfQoJCWNvdXQgPDwgY250IDw8IGVuZGw7Cgl9CglyZXR1cm4gMDsKfQ==