import numpy as np

def check(a,b,c,d,z_list):
    z = a
    ans = 'Yes'
    if a < b:
        ans = 'No'
        return ans,z_list
    z_list = [z] + z_list
    for k in range(10000000):
        x = (z - c)//b
        if x <= 0:
            x = 1
        z = z - b * x
        if z < 0:
            ans = 'No'
            break
        if z <= c:
            z += d
        
        if z in z_list:
            ans = 'Yes'
            break
        z_list.append(z)
#         print(z)
    return ans,z_list
def check_rec(rec,cd):
    z_list = []
    c = cd[0]
    d = cd[1]
    for k,cd in enumerate(rec[0][::-1]):
        if [c,d] == cd:
            z_list += (rec[1][k])
            break
    return z_list


t = int(input())
a = []
b = []
c = []
d = []
for k in range(t):
    aa,bb,cc,dd = list(map(int,input().split()))
    a.append(aa)
    b.append(bb)
    c.append(cc)
    d.append(dd)

aa = a
bb = b
cc = c
dd = d

cd_rec = []
z_rec  = []
ans_rec = []
rec = [[],[]]
for a,b,c,d in zip(aa,bb,cc,dd):
    
    z_list = check_rec(rec, [c,d])
    ans,z_list = check(a,b,c,d,z_list)
    rec[0].append([c,d])
    rec[1].append(z_list)

    print(ans)


