#include <bits/stdc++.h>
using namespace std;
long long bs(long long n, long long k, long long a, long long b) {
  int min1 = 0, max1 = n, res = -1;
  while (min1 <= max1) {
    int mid = (min1 + max1) / 2;
    if (mid * a + (n - mid) * b < k) {
      res = mid;
      min1 = mid + 1;
    } else
      max1 = mid - 1;
  }
  return res;
}
int main() {
  long long a, b, n, k;
  int t;
  cin >> t;
  while (t--) {
    cin >> k >> n >> a >> b;
    cout << bs(n, k, a, b) << endl;
  }
  return 0;
}
