#include<iostream>
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<<endl;
			}
			else if(N-K+1<=W)
			{
				cout<<-1<<endl;
			}
			else
			{
				cout<<":("<<endl;
			}
		}
		else
		{
			if(W%N==0)
			{
				if(A>=N-1)
				{
					long S=0;
					long T=W/N;
					S-=T*(T+1)/2;
					S+=(A-(N-1))/N;
					cout<<S<<endl;
				}
				else if(W>0)
				{
					long S=0;
					long T=W/N;
					S-=T*(T+1)/2;
					S-=T+1;
					if(A<=T)S+=A;
					else S+=T;
					cout<<S<<endl;
				}
				else
				{
					cout<<":("<<endl;
				}
			}
			else
			{
				int n=W%N;
				long S=0;
				long T=W/N;
				S-=T*(T+1)/2;
				T++;
				S-=T;
				if(T*n<=A)
				{
					S+=T;
					A-=T*n;
					if(A>=N-1)S+=(A-(N-1))/N;
					else
					{
						S--;
					}
				}
				else
				{
					N=n;
					if(A>=N-1)S+=(A-(N-1))/N;
					else
					{
						S-=T+1;
						if(A<=T)S+=A;
						else S+=T;
					}
				}
				cout<<S<<endl;
			}
		}
	}
}