#include <bits/stdc++.h>
using namespace std;
int a, b, c, d;
int main() {
  int T;
  cin >> T;
  while (T--) {
    cin >> a >> b >> c >> d;
    int x = a / b;
    int num = (d / b - c / b);
    if (c % b == 0) num++;
    cout << x - num << endl;
  }
  return 0;
}
