#include <bits/stdc++.h>
using namespace std;
int countDivisibles(int A, int B, int M) {
  if (A % M == 0) return (B / M) - (A / M) + 1;
  return (B / M) - (A / M);
}
int main() {
  long long int t, n, li, vi, l, r;
  cin >> t;
  while (t--) {
    cin >> li >> vi >> l >> r;
    long long int n1, n2;
    n1 = countDivisibles(1, li, vi);
    n2 = countDivisibles(l, r, vi);
    cout << n1 - n2 << endl;
  }
  return 0;
}
