#include <bits/stdc++.h>
using namespace std;
long long solve() {
  long long k, n, a, b;
  cin >> k >> n >> a >> b;
  if (n * b >= k) {
    cout << "-1\n";
  } else {
    long long lo = 0, hi = n;
    while (lo < hi) {
      long long mid = (lo + hi) / 2;
      mid++;
      if (mid * a + (n - mid) * b < k) {
        lo = mid;
      } else {
        hi = mid - 1;
      }
    }
    cout << lo << "\n";
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
}
