#include <bits/stdc++.h>
using namespace std;
long long int arr[300000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int TESTS, q, n, a, s, b, m, r, c, p, k, w, d, x, i, j, y, z, xs,
      ys, t;
  cin >> TESTS;
  while (TESTS--) {
    cin >> k >> n >> a >> b;
    if (b * n >= k)
      cout << -1;
    else {
      long long int dif = k - b * n - 1;
      cout << min(n, dif / (a - b));
    }
    cout << "\n";
  }
  return 0;
}
