#include <bits/stdc++.h>
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
const int MOD = 1e12 + 7;
const int MAX = 1e6 + 2;
const int INF = 0x3f3f3f3f;
using namespace std;
long long t, k, n, a, b, ans = 0;
int main() {
  cin >> t;
  while (t--) {
    cin >> k >> n >> a >> b;
    k -= b * n;
    if (k <= 0) {
      cout << -1 << endl;
      continue;
    }
    cout << min((k - 1) / (a - b), n) << endl;
  }
  return 0;
}
