#include <bits/stdc++.h>
using namespace std;
bool check(long long int k, long long int mid, long long int a, long long int b,
           long long int n) {
  long long int turns = 0;
  long long int totalturns = 0;
  if (k <= mid * a) {
    return false;
  }
  k -= mid * a;
  if (k <= (n - mid) * b) {
    return false;
  }
  return true;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int k, n, a, b;
    cin >> k >> n >> a >> b;
    long long int s = 0;
    long long int e = n;
    long long int ans = -1;
    while (s <= e) {
      long long int mid = s + (e - s) / 2;
      if (check(k, mid, a, b, n)) {
        ans = mid;
        s = mid + 1;
      } else {
        e = mid - 1;
      }
    }
    if (ans == -1) {
      if (k - n * b > 0) {
        ans = 0;
      }
    }
    if (ans == -1)
      cout << -1 << "\n";
    else
      cout << ans << "\n";
  }
}
