#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long lgput(long long a, long long b, long long mod) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ret;
}
int binarySearch(vector<int> &v, int value) {
  int best = 0;
  for (int step = 29; step >= 0; --step) {
    if (best + (1 << step) < v.size() && v[best + (1 << step)] <= value)
      best += (1 << step);
  }
  return best;
}
inline long long inv(long long x, long long MOD) {
  return lgput(x, MOD - 2, MOD);
}
const int MAXN = 200;
int v[MAXN];
char c[MAXN];
int dp[MAXN * MAXN][MAXN];
int inf = 1e9;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(12);
  cout << fixed;
  int t;
  cin >> t;
  while (t--) {
    int L, v, l, r;
    cin >> L >> v >> l >> r;
    cout << max(0, L / v - r / v + (l - 1) / v) << '\n';
  }
}
