#include using namespace std; using Int = long long; const char newl = '\n'; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a void drop(const T &x){cout< vector read(size_t n){ vector ts(n); for(size_t i=0;i>ts[i]; return ts; } //INSERT ABOVE HERE signed solve(){ Int n,a,w,k; cin>>n>>a>>w>>k; if(n==1){ cout<0){ // cout<<"A"<= 0 -> all WA canceled Int d=w/n,m=w%n; Int need=d*(d+1)/2*n+(d+1)*m+(k-1); if(need<=a){ cout<<(a-need)/n<(-1,a-w*(w+1)/2); cout<= 0 // (x + 1) * (k - 1) + x <= a // x * k + k - x - 1 + x <= a // x * k <= a - (k - 1) // x <= (a - (k - 1)) / k cout<< (a - (k - 1)) / k << newl; return 0; } signed main(){ cin.tie(0); ios::sync_with_stdio(0); Int T; cin>>T; while(T--) solve(); return 0; }