#include <bits/stdc++.h>
int main() {
  long long int i, j, a, L, v, x, y, count = 0;
  scanf("%lli", &a);
  for (i = 0; i < a; i++) {
    scanf("%lli %lli %lli %lli", &L, &v, &x, &y);
    count = L / v + (x - 1) / v - y / v;
    printf("%lli\n", count);
  }
}
