#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int L, v, li, ri;
    cin >> L >> v >> li >> ri;
    cout << L / v - (ri / v - (li - 1) / v) << endl;
  }
  return 0;
}
