#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void solve() {
  long long k, n, a, b;
  cin >> k >> n >> a >> b;
  if (b * n >= k) {
    cout << -1 << endl;
    return;
  }
  int l = 0;
  int r = n + 1;
  while (l < r) {
    int mid = (l + r) / 2;
    if (mid * a + (n - mid) * b >= k) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  cout << l - 1 << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    solve();
  }
  return 0;
}
