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