import math for _ in[0]*int(input()): D,A,B,K=map(int,input().split());g=math.gcd(D,A);l,h=0,A*B*K+2 if A*B%D<1 and D*K+g>=A:D,l,h=1,-1,0 while l+1