// Arup Guha
// 4/21/2024
// Solution to 2024 COP 4516 Team Final Contest Problem: How Many Integers in a Range?

import java.util.*;

public class ints {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process cases.
		for (int loop=0; loop<nC; loop++) {
		
			// Get input.
			long s = stdin.nextLong();
			long e = stdin.nextLong();
			long d = stdin.nextLong();
			
			// Find the last multiple <= e and first multiple >= s.
			// Use this to get the answer.
			System.out.println(myfloor(e,d)-myceiling(s,d)+1);
		}
	}
	
	public static long myfloor(long x, long d) {
		
		// Gets us close.
		long res = x/d;
		
		// For negatives, this might happen.
		if (res*d > x) res--;
		
		// Ta da!
		return res;
	}
	
	public static long myceiling(long x, long d) {
		
		// Gets us close.
		long res = x/d;
		
		// For positives, this might happen.
		if (res*d < x) res++;
		
		// Ta da!
		return res;
	}
	
	
}