#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a == b) return a;
  if (a > b) return gcd(a - b, b);
  return gcd(a, b - a);
}
void sol() {
  long long int L, v, l, r, count = 0;
  cin >> L >> v >> l >> r;
  long long int p = L / v;
  long long int q = (r / v) - ((l - 1) / v);
  cout << p - q << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) sol();
}
