#include <bits/stdc++.h>
using namespace std;
int main() {
  int ntests;
  cin >> ntests;
  while (ntests--) {
    int n, k, a, b;
    cin >> k >> n >> a >> b;
    if (k <= 1ll * n * b)
      cout << -1 << endl;
    else {
      long long x = (k - 1ll * n * b - 1) / (a - b);
      if (x > n) x = n;
      cout << x << endl;
    }
  }
}
