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