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