#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    long long k, n, a, b;
    long long num1, num2, ans;
    scanf("%lld %lld %lld %lld", &k, &n, &a, &b);
    if (k - n * b <= 0)
      printf("%d\n", -1);
    else {
      num1 = b * n;
      num2 = a - b;
      num1 = k - num1 - 1;
      ans = num1 / num2;
      printf("%lld\n", min(ans, n));
    }
  }
  return 0;
}
