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