#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, t, L, l, v, r, ans, a, b, c, d;
  scanf("%d", &n);
  while (n--) {
    scanf("%d%d%d%d", &L, &v, &l, &r);
    a = L / v;
    d = r / v - (l - 1) / v;
    ans = a - d;
    printf("%d\n", ans);
  }
  return 0;
}
