#include <bits/stdc++.h>
using namespace std;
void cp() {}
long long sm(long long n) {
  long long c = 0;
  while (n != 0) {
    c = c + n % 10;
    n = n / 10;
  }
  return c;
}
int main() {
  cp();
  long long t;
  cin >> t;
  while (t--) {
    vector<long long> u;
    map<long long, long long> p;
    map<long long, long long> q;
    vector<pair<long long, long long>> v;
    string s, st = "", str;
    char ch;
    long long n, i, j, x = -1, k = 0, ind = 0, y = 0, m, z = 0, a, b, c, d;
    cin >> n >> x >> y >> z;
    a = n - y - 1;
    b = n - z - 1;
    if (a > (x - 1) * y) {
      cout << x << endl;
      continue;
    }
    if (b < ((x - 1) * z)) {
      cout << "-1" << endl;
      continue;
    }
    c = b - (x - 1) * z;
    j = y - z;
    cout << c / j << endl;
  }
  return 0;
}
