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