#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int q;
  cin >> q;
  long long int k, n, a, b, ans;
  for (long long int p = 0; p < q; p++) {
    cin >> k >> n >> a >> b;
    ans = k - (n * b);
    if (ans > 0) {
      ans = min((ans - 1) / (a - b), n);
      cout << ans << '\n';
    } else
      cout << "-1\n";
  }
}
