#include <bits/stdc++.h>
using namespace std;
int main() {
  long long T, L, v, t, r, sum1 = 0, sum2 = 0, sum3 = 0, sum = 0;
  cin >> T;
  while (T--) {
    sum1 = 0, sum2 = 0, sum3 = 0, sum = 0;
    cin >> L >> v >> t >> r;
    sum1 = ((t - 1) / v);
    sum2 = (r / v);
    sum3 = (L / v);
    sum = sum3 - sum2 + sum1;
    cout << sum << endl;
  }
}
