#include <bits/stdc++.h>
using namespace std;
inline long long input() {
  long long n;
  cin >> n;
  return n;
}
const long long inf = 1e18, mod = 1e9 + 7, maxn = 1e5 + 10;
long long pw(long long a, long long b) {
  return (!b ? 1 : (b & 1 ? a * pw(a * a, b / 2) : pw(a * a, b / 2)));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    long long k, n, a, b;
    cin >> k >> n >> a >> b;
    if (n * b >= k) {
      cout << -1 << "\n";
      continue;
    }
    long long l = 0, r = n + 1;
    while (r - l > 1) {
      long long mid = (r + l) / 2;
      long long exy = (mid * a) + ((n - mid) * b);
      if (exy < k)
        l = mid;
      else
        r = mid;
    }
    cout << l << "\n";
  }
  return 0;
}
