#include <bits/stdc++.h>
using namespace std;
const int fx[] = {+1, -1, +0, +0};
const int fy[] = {+0, +0, +1, -1};
int Set(int &N, int pos) { return N = N | (1 << pos); }
int reset(int &N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second > b.second);
}
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  long long sqrtn = sqrt(n);
  for (long long i = 2; i <= sqrtn; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
void solve() {
  long long k, n, a, b;
  cin >> k >> n >> a >> b;
  long long lo = 0, hi = n;
  while (lo < hi) {
    long long mid = (lo + hi + 1) / 2;
    if (mid * a + (n - mid) * b < k) {
      lo = mid;
    } else
      hi = mid - 1;
  }
  if (n * b >= k)
    cout << -1 << "\n";
  else
    cout << hi << "\n";
}
int main() {
  init();
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
