#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0 || b == 0)
    return a + b;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    long long L, v, l, r;
    cin >> L >> v >> l >> r;
    long long a = L / v;
    a -= (r / v);
    a += ((l - 1) / v);
    cout << a << "\n";
  }
}
