#include <bits/stdc++.h>
using namespace std;
int main() {
  int t1;
  cin >> t1;
  while (t1--) {
    int n1, v1, l1, r1;
    cin >> n1 >> v1 >> l1 >> r1;
    cout << n1 / v1 - r1 / v1 + (l1 - 1) / v1 << endl;
  }
  return 0;
}
