#include <bits/stdc++.h>
using namespace std;
inline long long MAX2(long long a, long long int b) {
  return (a) > (b) ? (a) : (b);
}
inline long long MAX3(long long a, long long b, long long c) {
  return (a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c));
}
inline long long MIN2(long long a, long long b) {
  return (a) < (b) ? (a) : (b);
}
inline long long MIN3(long long a, long long b, long long c) {
  return (a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c));
}
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int L, v, l, r;
    cin >> L >> v >> l >> r;
    int cnt = (r / v) - (l - 1) / v;
    int ans = (L / v) - cnt;
    cout << ans << endl;
  }
  return 0;
}
