#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i;
  cin >> t;
  while (t) {
    long long int a, b, n, k;
    cin >> k >> n >> a >> b;
    if (k <= b * n)
      cout << -1 << "\n";
    else {
      long long int s = 0, e = n, ans = -1;
      while (s <= e) {
        long long int m = s + (e - s) / 2;
        if (k - m * a <= (n - m) * b)
          e = m - 1;
        else {
          ans = max(ans, m);
          s = m + 1;
        }
      }
      cout << ans << endl;
    }
    t--;
  }
}
