#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int L[n], v[n], l[n], r[n];
  for (int i = 0; i < n; i++) {
    int count = 0;
    cin >> L[i] >> v[i] >> l[i] >> r[i];
    r[i] = (r[i] / v[i] + 1) * v[i];
    if (r[i] > L[i]) {
      count += (l[i] - 1) / v[i];
    } else {
      count += (l[i] - 1) / v[i] + (L[i] - r[i]) / v[i] + 1;
    }
    cout << count << endl;
  }
  return 0;
}
