include
include <stdio.h>
include <stdlib.h>
using namespace std;
int main()
{
int T;
scanf("%d",&T);
long long n,m,v,k;
while(T--)
{
cin>>n>>m>>v>>k;
int ans=0;
if(n<=m)
{
ans=0;
}else if( m <v || (m-v)*k <= m) // k=0 0<= m
{
ans=-1;
}else {
while(n>m)
{
m= (m-v)*k;
ans++;
}
}
printf("%d
",ans);
}
return 0;
}