#include <bits/stdc++.h>
using namespace std;
int t, s, v, l, r;
int main() {
  cin >> t;
  while (t--) {
    scanf("%d%d%d%d", &s, &v, &l, &r);
    cout << (s / v) - (r / v - (l - 1) / v) << endl;
  }
  return 0;
}
