#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long L, v, l, r;
    cin >> L >> v >> l >> r;
    long long tot = L / v;
    long long minus = r / v;
    minus -= (l - 1) / v;
    cout << tot - minus << "\n";
  }
  return 0;
}
