#include <bits/stdc++.h>
namespace io {
template <typename T>
inline void read(T& a) {
  int c = getchar(), sign = 0;
  a = 0;
  while (c < '0' || c > '9') sign += (c == '-'), c = getchar();
  while (c >= '0' && c <= '9') a = (a << 1) + (a << 3) + c - 48, c = getchar();
  if (sign & 1) a = -a;
}
template <typename T, typename... _T>
inline void read(T& a, _T&... argc) {
  read(a);
  read(argc...);
}
template <typename T>
inline void Write(T a) {
  if (a > 9) Write(a / 10);
  putchar(a % 10 + '0');
}
template <typename T>
inline void write(T a, char ch = ' ') {
  if (a < 0) putchar('-'), a = -a;
  Write(a);
  putchar(ch);
}
}  // namespace io
using namespace io;
using namespace std;
const int maxn = 5e5;
const int mod = 1e9 + 7;
int n, d, m, q, a[maxn + 3], b[maxn + 3];
int dem[maxn + 3], id[maxn + 3], chot[maxn + 3];
int k, h;
long long dp[maxn + 5], t[maxn + 3];
string second;
bool kt[maxn + 3];
map<int, int> maps;
vector<int> edge[maxn + 3];
map<int, int>::iterator it;
template <typename T>
void answer(T x) {
  cout << x;
  exit(0);
}
void putstring(string x, char ch = ' ') {
  for (char c : x) putchar(c);
  putchar(ch);
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  cin >> q;
  while (q--) {
    int l, r;
    cin >> k >> n >> r >> l;
    if (k <= 1ll * n * l)
      cout << "-1\n";
    else {
      int res = (k - 1ll * l * n) / (r - l);
      if ((k - 1ll * l * n) % (r - l) > 0) res++;
      cout << min(res - 1, n) << "\n";
    }
  }
}
