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