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