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