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