#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
long long t, k, n, a, b, ans1, ans2;
void ef(int l, int r) {
  if (l == r) return;
  int m = (l + r) / 2;
  if ((m * a) + (n - m) * b < k) {
    ans1 = m;
    ef(m + 1, r);
  } else
    ef(l, m);
}
int main() {
  cin >> t;
  while (t--) {
    cin >> k >> n >> a >> b;
    ans1 = -1;
    long long l = 0, r = n;
    while (l <= r) {
      int m = (l + r) / 2;
      if ((m * a) + (n - m) * b < k) {
        ans1 = m;
        l = m + 1;
      } else
        r = m - 1;
    }
    cout << ans1 << endl;
  }
}
