#include <bits/stdc++.h>
int main() {
  int L[10000], v[10000], l[10000], r[10000], x, n = 0, t;
  scanf("%d", &t);
  for (x = 0; x < t; x++) {
    scanf("%d %d %d %d", &L[x], &v[x], &l[x], &r[x]);
  }
  for (x = 0; x < t; x++) {
    n = (l[x] - 1) / v[x];
    n = n + L[x] / v[x] - r[x] / v[x];
    printf("%d", n);
    if (x < t - 1) printf("\n");
    n = 0;
  }
  return 0;
}
