#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, L, v, l, r;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> L >> v >> l >> r;
    if (l % v == 0) {
      cout << L / v - r / v + l / v - 1 << endl;
      continue;
    } else {
      cout << L / v - r / v + l / v << endl;
      continue;
    }
  }
}
