parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function purchase(a,b,c,d)
	now = a
	set = Int[]
	while 0==0
		k = div(now-c,b)
		if now-b*k == c
			push!(set,c)
			now = now-b*k+d
		else
			now = now-b*(k+1)
			if now < 0
				println("No")
				break
			end
			if now in set
				println("Yes")
				break
			end
			push!(set,now)
			now += d
		end
	end
end

function main()
	t = readline() |> parseInt
	for i in 1:t
		a,b,c,d = readline() |> split |> parseMap
		purchase(a,b,c,d)
	end
end

main()