#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    long long L, v, l, r;
    cin >> L >> v >> l >> r;
    long long colLantern = L / v - (r / v) + (l / v);
    if (l % v == 0) colLantern--;
    cout << colLantern << endl;
  }
  return 0;
}
