import math
for test in range(int(input())):
l,r,g=map(int,input().split())
i=math.ceil(l/g)*g
j=math.floor(r/g)*g
if i==j and i!=g:
print(0)
else:
print((j-i)//g+1)
aW1wb3J0IG1hdGgKZm9yIHRlc3QgaW4gcmFuZ2UoaW50KGlucHV0KCkpKToKICAgIGwscixnPW1hcChpbnQsaW5wdXQoKS5zcGxpdCgpKQogICAgaT1tYXRoLmNlaWwobC9nKSpnCiAgICBqPW1hdGguZmxvb3Ioci9nKSpnCiAgICBpZiBpPT1qIGFuZCBpIT1nOgogICAgCXByaW50KDApCiAgICBlbHNlOgogICAgCXByaW50KChqLWkpLy9nKzEp