#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a > b) {
    swap(a, b);
  }
  if (a == 0) return b;
  return gcd(b % a, a);
}
int invertBits(int num) {
  int x = log2(num) + 1;
  for (int i = 0; i < x; i++) num = (num ^ (1 << i));
  return num;
}
int main() {
  long long int q;
  cin >> q;
  while (q--) {
    long long int n, k, a, b;
    cin >> k >> n >> a >> b;
    if (k - b * n <= 0) {
      cout << "-1" << endl;
      continue;
    }
    long long int l = 0, h = n, mid, ans = -1;
    while (l <= h) {
      mid = l + (h - l) / 2;
      if (k > mid * a + (n - mid) * b) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
