#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int L, v, l, r;
    cin >> L >> v >> l >> r;
    long long int count = 0;
    long long int p, q, s;
    if (l % v == 0) count += 1;
    p = l / v;
    q = r / v;
    s = L / v - (q - p) - count;
    cout << s << endl;
  }
  return 0;
}
