#include <bits/stdc++.h>
using namespace std;
const int N = 1234567;
;
const long long INF = 4e18;
long long q, k, n, a, b, l, r, mid, mx = -INF;
long long f(long long x) { return k - x * a - (n - x) * b; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> q;
  while (q--) {
    cin >> k >> n >> a >> b;
    l = 0;
    r = n;
    while (l < r) {
      mid = l + (r - l) / 2;
      if (f(mid) < 1) {
        r = mid - 1;
      } else {
        l = mid;
      }
      if (r - l == 1) {
        break;
      }
    }
    if (f(r) < 1 && f(l) < 1) {
      cout << "-1\n";
      continue;
    }
    cout << (f(r) >= 1 ? r : l) << "\n";
  }
  return 0;
}
