#include <bits/stdc++.h>
using namespace std;
int main() {
  int cases;
  cin >> cases;
  while (cases--) {
    long long L, v, l, r, lmod, z;
    cin >> L >> v >> l >> r;
    lmod = l % v;
    if (lmod != 0) l += (v - lmod);
    r -= r % v;
    if (l > r)
      z = 0;
    else
      z = (r - l) / v + 1;
    cout << L / v - z << endl;
  }
  return 0;
}
