#include <bits/stdc++.h>
using namespace std;
bool valid(long long ch, long long n, long long a, long long b,
           long long testNum) {
  long long ch_only = a * testNum;
  long long ch_and_ply = b * (n - testNum);
  long long total = ch_and_ply + ch_only;
  return total < ch;
}
long long generateNum(long long ch, long long n, long long a, long long b) {
  long long right = 0, left = n;
  long long mid = (right + left) / 2;
  while (left - right > 1) {
    if (valid(ch, n, a, b, mid))
      right = mid;
    else
      left = mid;
    mid = (right + left) / 2;
  }
  if (valid(ch, n, a, b, right)) {
    if (valid(ch, n, a, b, left))
      return left;
    else
      return right;
  } else
    return -1;
}
int main() {
  int q;
  cin >> q;
  while (q--) {
    long long ch, n, a, b;
    cin >> ch >> n >> a >> b;
    long long ans = generateNum(ch, n, a, b);
    cout << ans << endl;
  }
  return 0;
}
