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