#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma comment(linker, "/STACK:102400000,102400000")
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int EXP = 1e-8;
const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
using namespace std;
int main() {
  int t;
  cin >> t;
  long long L, v, l, r;
  long long ans;
  while (t--) {
    cin >> L >> v >> l >> r;
    ans = L / v - 1 / v;
    if (v == 1) ans++;
    ans -= (r / v - l / v);
    if (l % v == 0) ans--;
    cout << ans << endl;
  }
  return 0;
}
