N = int(input())

inputs = [input().split(" ") for _ in range(N)]    


for input in inputs:
    # print(input)
    A = int(input[0])
    B = int(input[1])
    C = int(input[2])
    D = int(input[3])
    FLAG = True
    asa = A
    start_roop = None
    while FLAG:
        yoru = asa - B
        if start_roop is None:
            start_roop = yoru
        # print("yoru : {}. start_roop : {}".format(yoru, start_roop))
        if yoru != start_roop:
            if yoru < 0:
                print("No")
                FLAG = False
                break
            elif yoru <= C:
                
                yoru += D
            print(yoru)
        else:
            print("Yes")
            FLAG = False
            break