#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, L, v, l, r;
  cin >> t;
  while (t--) {
    cin >> L >> v >> l >> r;
    cout << L / v - r / v + l / v - (l % v == 0 ? 1 : 0) << "\n";
  }
  return 0;
}
