#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& a) {
  os << "{";
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? "," : "") << a[i];
  return os << "}";
}
[[maybe_unused]] constexpr ll MOD = 998244353;
[[maybe_unused]] constexpr int INF = 0x3f3f3f3f;
[[maybe_unused]] constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;
ll solve(ll v, ll l) { return l / v; }
int main() {
  int t;
  cin >> t;
  while (t--) {
    ll L, v, l, r;
    cin >> L >> v >> l >> r;
    cout << solve(v, L) - (solve(v, r) - solve(v, l - 1)) << '\n';
  }
  return 0;
}
