#include <bits/stdc++.h>
using namespace std;
void show(vector<int> v) {
  for (vector<int>::iterator it = v.begin(); it != v.end(); it++) {
    cout << *it << " ";
  }
  cout << endl;
}
int main() {
  int t;
  cin >> t;
  int L, v, l, r;
  int sum1 = 0, sum2 = 0, t_sum = 0;
  while (t--) {
    cin >> L >> v >> l >> r;
    sum1 = L / v;
    sum2 = (r / v - (l - 1) / v);
    t_sum = (sum1 - sum2);
    cout << t_sum << endl;
  }
  return 0;
}
