#include <bits/stdc++.h>
using namespace std;
long long k, n, a, b;
int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> k >> n >> a >> b;
    if (n * b >= k) {
      cout << "-1" << endl;
    } else {
      long long l = 0;
      long long r = n;
      long long ans = 0;
      while (l <= r) {
        long long m = (l + r) / 2;
        if (m * a + (n - m) * b < k) {
          ans = m;
          l = m + 1;
        } else {
          r = m - 1;
        }
      }
      cout << ans << endl;
    }
  }
}
