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