#include <bits/stdc++.h>
using namespace std;
int k, n, a, b;
bool ok(int ter) { return k > (long long)a * ter + (long long)b * (n - ter); }
void solve() {
  cin >> k >> n >> a >> b;
  if (!ok(0)) {
    cout << "-1\n";
    return;
  }
  if (ok(n)) {
    cout << n << '\n';
    return;
  }
  long long L = 0, R = n;
  while (L + 1 < R) {
    int m = (L + R) >> 1;
    (ok(m) ? L : R) = m;
  }
  cout << L << '\n';
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
