#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e4 + 5;
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    long long k, n, a, b;
    cin >> k >> n >> a >> b;
    if (n * b >= k)
      cout << -1 << "\n";
    else {
      long long c = a - b;
      cout << min(n, (k - n * b - 1) / c) << "\n";
    }
  }
  return 0;
}
