#include <bits/stdc++.h>
using namespace std;
bool check(long long k, long long n, long long a, long long b, long long m) {
  long long temp = m * a + (n - m) * b;
  if (temp < k)
    return true;
  else
    return false;
}
int main(void) {
  long long q;
  cin >> q;
  while (q--) {
    long long k, n, a, b;
    cin >> k >> n >> a >> b;
    long long h = n, l = 0, m;
    if (n * b >= k)
      cout << "-1"
           << "\n";
    else {
      while ((h - l) > 1) {
        m = (h + l) / 2;
        if (check(k, n, a, b, m)) {
          l = m;
        } else {
          h = m - 1;
        }
      }
      if (check(k, n, a, b, max(l, h)))
        cout << max(l, h) << "\n";
      else
        cout << min(l, h) << "\n";
    }
  }
}
