#include <bits/stdc++.h>
using namespace std;
long long t, v[100005], L[100005], l[100005], r[100005];
int main() {
  cin >> t;
  for (long long i = 1; i <= t; i++) {
    cin >> L[i] >> v[i] >> l[i] >> r[i];
    cout << L[i] / v[i] - r[i] / v[i] + (l[i] - 1) / v[i] << endl;
  }
}
