#include <bits/stdc++.h>
const long double eps = 1e-9;
const long double Pi = acos(-1);
const long long md = (1e9 + 7);
const long long fakmd = 998244353;
using namespace std;
long long q, k, n, a, b;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> q;
  while (q--) {
    cin >> k >> n >> a >> b;
    if (k <= n * b) {
      cout << -1 << "\n";
      continue;
    }
    long long l = 0, r = n;
    while (r - l > 0) {
      long long mid = (l + r + 1) / 2;
      if (a * mid + (n - mid) * b >= k) {
        r = mid - 1;
      } else {
        l = mid;
      }
    }
    cout << l << "\n";
  }
  return 0;
}
