#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long k, n, a, b;
    cin >> k >> n >> a >> b;
    k -= n * a;
    if (k > 0)
      cout << n << "\n";
    else {
      k = -k;
      long long int d = a - b;
      long long int turns = (k + d) / d;
      if (turns > n) {
        cout << -1 << "\n";
      } else {
        cout << n - turns << "\n";
      }
    }
  }
}
