#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, v, l, r;
    cin >> n >> v >> l >> r;
    if (n < v) {
      cout << 0 << "\n";
      continue;
    }
    int total = n / v;
    int count = r / v - l / v;
    if (l % v == 0) {
      count++;
    }
    cout << total - count << "\n";
  }
  return 0;
}
