#include <bits/stdc++.h>
using namespace std;
void use_cio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
template <typename... Args>
void dbg(Args... args) {
  ((cout << args << " "), ...);
  cout << "\n";
}
int main() {
  use_cio();
  int tc;
  cin >> tc;
  while (tc--) {
    long long L, v, l, r;
    cin >> L >> v >> l >> r;
    cout << L / v - r / v + (l - 1) / v << "\n";
  }
}
