t = int(input())
for i in range(t):
    a, b, c, d = map(int, input().split())
    rec = [a]
    flag = False
    num = 0
    while True and num < 100000:
        if a < b:
            break
        else:
            a = a % b
        if a <= c:
            a += d
        if a in rec:
            flag = True
            break
        num += 1
        rec.append(a)
    if flag:
        print("YES")
    else:
        print("NO")