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