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