#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long T, n, i, k, t, a, b, x, w;
  long long j;
  cin >> T;
  while (T--) {
    cin >> k >> n >> a >> b;
    t = 0, w = 0;
    if (b * n >= k)
      cout << -1 << endl;
    else {
      t = k - (b * n);
      x = a - b;
      j = t / x;
      if (j > n) j = n;
      if ((j * a + (n - j) * b) >= k)
        cout << j - 1 << endl;
      else
        cout << j << endl;
    }
  }
  return 0;
}
