#include <bits/stdc++.h>
using namespace std;
long long q, k, n, a, b, ans;
int main() {
  cin >> q;
  while (q--) {
    ans = -1;
    cin >> k >> n >> a >> b;
    long long r = n, l = 0, mid;
    while (l <= r) {
      mid = (l + r) / 2;
      long long test = (mid * b) + ((n - mid) * a);
      if (test >= k) {
        l = mid + 1;
      } else {
        ans = (n - mid);
        r = mid - 1;
      }
    }
    cout << ans << "\n";
  }
}
