#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int L, v, l, r;
    cin >> L >> v >> l >> r;
    if (v > L) {
      cout << "0" << endl;
      continue;
    }
    long long int x = L / v;
    long long int y = r / v;
    long long int z = (l - 1) / v;
    cout << x - (y - z) << endl;
  }
  return 0;
}
