#include using namespace std; int T; main() { cin>>T; for(;T--;) { int N,A,W,K; cin>>N>>A>>W>>K; if(N>K) { if(K-1<=A) { cout<<(A-(K-1))/K<S)s--; cout<