#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  long long k, n, a, b, res = 0;
  bool flag;
  while (q--) {
    flag = false;
    cin >> k >> n >> a >> b;
    if (k <= n * b) flag = true;
    if (flag == true)
      cout << "-1\n";
    else {
      long long low = 0, high = n, mid = 0;
      while (low <= high) {
        mid = low + (high - low) / 2;
        if (a * mid + b * (n - mid) >= k)
          high = mid - 1;
        else
          low = mid + 1;
      }
      cout << high << "\n";
    }
  }
  return 0;
}
