#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5, M = N * 4;
const long long MOD = 1e9 + 7, oo = 1e9, OO = 1e18;
long long di[] = {1, -1, 0, 0};
long long dj[] = {0, 0, 1, -1};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long k, n, a, b;
    cin >> k >> n >> a >> b;
    if (n * b >= k)
      cout << -1;
    else {
      long long l = 0, r = n, md;
      while (l < r) {
        md = (l + r + 1) / 2;
        if (k - md * a > (n - md) * b)
          l = md;
        else
          r = md - 1;
      }
      cout << l;
    }
    cout << '\n';
  }
}
