#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, L, l, r, v, ans;
  cin >> t;
  for (long long int i = 1; i <= t; i++) {
    ans = 0;
    cin >> L >> v >> l >> r;
    ans = (L / v) - (r) / v + (l - 1) / v;
    cout << ans << endl;
  }
}
