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