#include <bits/stdc++.h>
using namespace std;
int T, N, V, L, R, ans;
int main() {
  cin >> T;
  while (T--) {
    cin >> N >> V >> L >> R;
    ans = (L - 1) / V;
    R += V - (R % V);
    if (R <= N) ans += (N - R) / V + 1;
    cout << ans << endl;
  }
  return 0;
}
