#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int llINF = 0x3f3f3f3f3f3f3f;
const int MAXN = 100100;
const long long int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, v, l, r;
    cin >> n >> v >> l >> r;
    int tot, esq, dir;
    tot = n / v;
    dir = r / v;
    esq = l / v;
    if (l % v == 0) esq--;
    cout << tot - (dir - esq) << endl;
  }
}
