#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int l, v, a, b;
    cin >> l >> v >> a >> b;
    int k = l / v - b / v + a / v;
    if (a % v == 0) {
      k--;
    }
    cout << k << endl;
  }
  return 0;
}
