#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T, cnt = 0;
  cin >> T;
  while (T--) {
    long long int k, n, a, b;
    cin >> k >> n >> a >> b;
    k -= n * a;
    if (k > 0)
      cout << n << "\n";
    else {
      k = -k;
      long long int dif = a - b;
      long long int turns = (k + dif) / dif;
      if (turns > n)
        cout << "-1\n";
      else
        cout << n - turns << "\n";
    }
  }
  return 0;
}
