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