#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
inline long long int input() {
  long long int n;
  cin >> n;
  return n;
}
long long int pw(long long int a, long long int b) {
  return (!b ? 1 : (b & 1 ? a * pw(a * a, b / 2) : pw(a * a, b / 2)));
}
const long long int MAXN = 2e5 + 10;
const long long int MAXA = 101;
const long long int INF = 8e18;
const long long int MOD = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
  ;
  long long int t;
  cin >> t;
  while (t--) {
    long long int L, v, l, r;
    cin >> L >> v >> l >> r;
    long long int bib = L / v;
    long long int bib1 = l / v - (l % v == 0), bib2 = r / v;
    long long int x = bib2 - bib1;
    cout << bib - x << endl;
  }
  return 0;
}
