#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double EXP = 1e-9;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int L, v, l, r;
    cin >> L >> v >> l >> r;
    int cnt = L / v;
    int seg = r / v - l / v;
    if (l % v == 0) seg++;
    cout << cnt - seg << '\n';
  }
  return 0;
}
