#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    int d, v, l, r;
    cin >> d >> v >> l >> r;
    cout << d / v - r / v + (l - 1) / v << endl;
  }
}
