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