#include <bits/stdc++.h>
using namespace std;
long long int n, L, v, l, r;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  while (n--) {
    cin >> L >> v >> l >> r;
    cout << (L / v) - ((r / v) - ((l - 1) / v)) << endl;
  }
}
