#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long double l, w, a, b;
    cin >> l >> w >> a >> b;
    cout << setprecision(20)
         << (int)floor(l / w) - floor(floor(b / w) - ceil(a / w) + 1) << endl;
  }
}
