#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int L, v, l, r, sum = 0, z = 0;
    for (int i = 0; i < 10000; i++) z++;
    int s1, s2, s3;
    for (int i = 0; i < 10000; i++) z++;
    scanf("%d%d%d%d", &L, &v, &l, &r);
    s1 = L / v;
    if (l % v == 0)
      s2 = l / v - 1;
    else
      s2 = l / v;
    s3 = r / v;
    for (int i = 0; i < 10000; i++) z++;
    printf("%d\n", s1 - s3 + s2);
  }
  return 0;
}
