#include <bits/stdc++.h>
long long mod = 1000000007;
using namespace std;
vector<long long> adj[26];
vector<long long> adj1[26];
stack<long long> s;
set<long long> vis;
vector<pair<long long, long long>> visited(26);
vector<pair<long long, long long>> latest(26);
bool imp = 0;
int main() {
  long long n, q, sum = 0, m, x, i, j, mn, mx;
  cin >> q;
  for (long long ii = 0; ii < q; ii++) {
    long long k, a, b;
    cin >> k >> n >> a >> b;
    if (b * n >= k) {
      cout << "-1\n";
      continue;
    }
    m = n;
    long long start = 1, end = n, mid, ans = 0;
    while (start <= end) {
      mid = (start + end) / 2;
      m = mid;
      if (mid == ans) {
        break;
      }
      if ((m * a) + ((n - m) * b) < k) {
        start = mid + 1;
        ans = mid;
      } else {
        end = mid - 1;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
