Problem:
 Score : 600 points    Problem Statement Ringo Mart, a convenience store, sells apple juice.  On the opening day of Ringo Mart, there were A cans of juice in stock in the morning.
Snuke buys B cans of juice here every day in the daytime.
Then, the manager checks the number of cans of juice remaining in stock every night.
If there are C or less cans, D new cans will be added to the stock by the next morning.  Determine if Snuke can buy juice indefinitely, that is, there is always B or more cans of juice in stock when he attempts to buy them.
Nobody besides Snuke buy juice at this store.  Note that each test case in this problem consists of T queries.      Constraints  1 \leq T \leq 300  1 \leq A, B, C, D \leq 10^{18}  All values in input are integers.         Input Input is given from Standard Input in the following format:  T  A_1  B_1  C_1  D_1  A_2  B_2  C_2  D_2  :  A_T  B_T  C_T  D_T   In the i -th query, A = A_i, B = B_i, C = C_i, D = D_i .      Output Print T lines. The i -th line should contain Yes if Snuke can buy apple juice indefinitely in the i -th query; No otherwise.        Sample Input 1 14
9 7 5 9
9 7 6 9
14 10 7 12
14 10 8 12
14 10 9 12
14 10 7 11
14 10 8 11
14 10 9 11
9 10 5 10
10 10 5 10
11 10 5 10
16 10 5 10
1000000000000000000 17 14 999999999999999985
1000000000000000000 17 15 999999999999999985      Sample Output 1 No
Yes
No
Yes
Yes
No
No
Yes
No
Yes
Yes
No
No
Yes  In the first query, the number of cans of juice in stock changes as follows: (D represents daytime and N represents night.)  9  → D  2  → N  11  → D  4  → N  13  → D  6  → N  6  → D x  In the second query, the number of cans of juice in stock changes as follows:  9  → D  2  → N  11  → D  4  → N  13  → D  6  → N  15  → D  8  → N  8  → D  1  → N  10  → D  3  → N  12  → D  5  → N  14  → D  7  → N  7  → D  0  → N  9  → D  2  → N  11  → D …  and so on, thus Snuke can buy juice indefinitely.       Sample Input 2 24
1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
1 4 2 3
1 4 3 2
2 1 3 4
2 1 4 3
2 3 1 4
2 3 4 1
2 4 1 3
2 4 3 1
3 1 2 4
3 1 4 2
3 2 1 4
3 2 4 1
3 4 1 2
3 4 2 1
4 1 2 3
4 1 3 2
4 2 1 3
4 2 3 1
4 3 1 2
4 3 2 1      Sample Output 2 No
No
No
No
No
No
Yes
Yes
No
No
No
No
Yes
Yes
Yes
No
No
No
Yes
Yes
Yes
No
No
No

Solution (Python):
import math

t = int(input())

for i in range(t):
    a, b, c, d = list(map(int, input().split()))

    if b > d:
        
        print('No')
        continue
    if a < b:
        
        print('No')
        continue
    if b == d:
        

        if a <= c:
            
            print('Yes')
            continue

        diff = a-c
        buy_num = (diff + b - 1) // b
        if a - buy_num * b < 0:
            print('No')
            continue
        else:
            print('Yes')
            continue
    
    if b < d:
        
        
        
        
        
        
        
        
        
        
        
        
        
        

        if math.gcd(b, d) == 1:
            if c-b+1 >= 0:
                print('Yes')
                continue
            else:
                print('No')
                continue
        else:
            
            
            
            g = math.gcd(b, d)
            diff = a - (c+1)
            subtract_width = diff // g * g
            if a - subtract_width >= b:
                print('Yes')
                continue
            else:
                print('No')
                continue

Solution (Python):
def solve(P):
    A, B, C, D = P
    if A<B or D<B:
        return False
    if C >= B-1:
        return True
    g = gcd(B,D)
    return A%B+(B-A%B-1)//g*g <= C

from math import gcd

T = int(input())
for _ in range(T):
    P = map(int, input().split())
    print("Yes" if solve(P) else "No")

Solution (Python):
def solve(P):
    A, B, C, D = P
    if A<B or D<B:
        return False
    if C >= B-1:
        return True
    g = gcd(B,D)
    return A%g + ((B-A%g-1)//g)*g <= C

from math import gcd

T = int(input())
for _ in range(T):
    P = map(int, input().split())
    print("Yes" if solve(P) else "No")

Solution (Python):
def solve(P):
    A, B, C, D = P
    if A<B or D<B:
        return False
    if C >= B-1:
        return True
    g = gcd(B,D)
    return B + A%g - g <= C

from math import gcd

T = int(input())
for _ in range(T):
    P = map(int, input().split())
    print("Yes" if solve(P) else "No")

Solution (Python):
from math import gcd

def solve(a,b,c,d):
  
    if a < b:
        return False
    if d < b:
        return False

    g = gcd(b,d)
    m = b - (b-a-1)%g - 1
    return m <= c

T = int(input())
for _ in range(T):
    print('Yes' if solve(*map(int,input().split())) else 'No')

Solution (Python):
import math
for _ in range(int(input())):
    a,b,c,d = map(int,input().split())
    print('Yes' if b <= min(a, d, c+1+(a-c-1)%math.gcd(b,d)) else 'No')

Solution (Python):
from math import gcd

def solve(a,b,c,d):
  
    if a < b:
        return False
    if d < b:
        return False

    g = gcd(b,d)
    c += 1
    m = c + (a-c)%g
    return b <= m

T = int(input())
for _ in range(T):
    print('Yes' if solve(*map(int,input().split())) else 'No')

Solution (Python):
def main(a,b,c,d):
  if a<b:return 'No'
  if d<b:return 'No'
  if b<=c+1:return 'Yes'
  if d%b==0:
    if a%b<=c:return 'Yes'
    return 'No'
  
  import math
  g=math.gcd(d%b,b)
  e0=a%d
  if g*((b-1-e0)//g)+e0<=c:return 'Yes'
  return 'No'


t=int(input())
abcd=[list(map(int,input().split())) for _ in range(t)]
for a,b,c,d in abcd:
  print(main(a,b,c,d))

Solution (Python):

















import math


def solve(A, B, C, D):
    if A < B or A % B > C:
        return 'No'
    if D < B:
        return 'No'
    if D == B:
        return 'Yes'
    
    if B <= C + 1:
        return 'Yes'
    g = math.gcd(B, D)
    n = (B - 1 - (A % B)) // g
    s = A % B + n * g
    if C + 1 <= s <= B - 1:
        return 'No'
    return 'Yes'


def main():
    T = int(input())
    ans = list()
    for _ in range(T):
        A, B, C, D = map(int, input().split())
        ans.append(solve(A, B, C, D))
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Solution (Python):
from math import gcd

t = int(input())
queries = [tuple(int(x) for x in input().split()) for _ in range(t)]
for a, b, c, d in queries:
    if a < b:
        print("No")
        continue
    if b > d:
        print("No")
        continue
    if b - c <= 1:
        print("Yes")
        continue

    g = gcd(b, d)
    m = a + ((b - a) // g) * g
    if m >= b:
        m -= g
    if c < m:
        print("No")
    else:
        print("Yes")

Solution (Python):
from math import gcd

t = int(input())
queries = [tuple(int(x) for x in input().split()) for _ in range(t)]
for a, b, c, d in queries:
    if a < b:
        print("No")
        continue
    if b > d:
        print("No")
        continue
    if b - c <= 1:
        print("Yes")
        continue

    g = gcd(-b, d)
    if g == 1 or b - c > g:
        print("No")
    else:
        m = a - ((a - c) // g) * g
        if c < m < b:
            print("No")
        else:
            print("Yes")

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from math import gcd

    def judge(a, b, c, d):
        if a - b < 0:
            return False
        else:
            if d - b < 0:
                return False

            first = a - b

            l = c + 1
            r = b - 1
            x = gcd(b, d)

            mod_min = first + (first - l + x - 1) // x * x
            mod_max = first + (r - first) // x * x
            if l <= mod_min <= r or l <= mod_max <= r:
                return False
            else:
                return True

    T = int(readline())

    for _ in range(T):
        a, b, c, d = map(int, readline().split())
        print("Yes") if judge(a, b, c, d) else print("No")


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

import math
import decimal

ctx = decimal.Context(prec=1, rounding=decimal.ROUND_CEILING)

for i in range(int(input())):
    a, b, c, d = map(int, input().split())

    if a < b:
        print('No')
        continue

    if b > d:
        print('No')
        continue

    if c >= b:
        print('Yes')
        continue

    g = gcd(b, d)
    r = a % g
    
    

    
    
    

    
    _max = ((b - r + g - 1)//g) * g + r - g
    if c < _max:
        print('No')
    else:
        print('Yes')

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

import math
import decimal

ctx = decimal.Context(prec=1, rounding=decimal.ROUND_CEILING)

for i in range(int(input())):
    a, b, c, d = map(int, input().split())

    if a < b:
        print('No')
        continue

    if b > d:
        print('No')
        continue

    if c >= b:
        print('Yes')
        continue

    g = gcd(b, d)
    r = a % g
    
    _max = (int(((decimal.Decimal(b, context=ctx) - decimal.Decimal(r, context=ctx)) / decimal.Decimal(g, context=ctx)).to_integral_exact(context=ctx)) * g) + r - g

    
    

    
    
    if c < _max:
        print('No')
    else:
        print('Yes')

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

import math
import decimal

ctx = decimal.Context(prec=3, rounding=decimal.ROUND_CEILING)

for i in range(int(input())):
    a, b, c, d = map(int, input().split())

    if a < b:
        print('No')
        continue

    if b > d:
        print('No')
        continue

    if c >= b:
        print('Yes')
        continue

    g = gcd(b, d)
    r = a % g
    
    _max = (int(((decimal.Decimal(b, context=ctx) - decimal.Decimal(r, context=ctx)) / decimal.Decimal(g, context=ctx)).to_integral_exact(context=ctx)) * g) + r - g

    
    

    
    
    if c < _max:
        print('No')
    else:
        print('Yes')

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

import math
import decimal

ctx = decimal.Context(prec=5, rounding=decimal.ROUND_CEILING)

for i in range(int(input())):
    a, b, c, d = map(int, input().split())

    if a < b:
        print('No')
        continue

    if b > d:
        print('No')
        continue

    if c >= b:
        print('Yes')
        continue

    g = gcd(b, d)
    r = a % g
    
    _max = (int(((decimal.Decimal(b, context=ctx) - decimal.Decimal(r, context=ctx)) / decimal.Decimal(g, context=ctx)).to_integral_exact(context=ctx)) * g) + r - g

    
    

    
    
    if c < _max:
        print('No')
    else:
        print('Yes')

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

import math
import decimal

ctx = decimal.Context(prec=100, rounding=decimal.ROUND_CEILING)

for i in range(int(input())):
    a, b, c, d = map(int, input().split())

    if a < b:
        print('No')
        continue

    if b > d:
        print('No')
        continue

    if c >= b:
        print('Yes')
        continue

    g = gcd(b, d)
    r = a % g
    _max = (int(((decimal.Decimal(b, context=ctx) - decimal.Decimal(r, context=ctx)) / decimal.Decimal(g, context=ctx)).to_integral_exact(context=ctx)) * g) + r - g
    
    
    if c < _max:
        print('No')
    else:
        print('Yes')

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

import math

for i in range(int(input())):
    a, b, c, d = map(int, input().split())

    if a < b:
        print('No')
        continue

    if b > d:
        print('No')
        continue

    if c >= b:
        print('Yes')
        continue

    g = gcd(b, d)
    r = a % g
    
    _max = b + r - g
    
    
    if c < _max:
        print('No')
    else:
        print('Yes')

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

import math

for i in range(int(input())):
    a, b, c, d = map(int, input().split())

    if a < b:
        print('No')
        continue

    if b > d:
        print('No')
        continue

    if c >= b:
        print('Yes')
        continue

    g = gcd(b, d)
    r = a % g
    
    _max = ((b - r + g - 1)//g) * g + r - g
    if c < _max:
        print('No')
    else:
        print('Yes')

Solution (Python):
import math

t=int(input()) 
for i in range(t):
    a,b,c,d=map(int,input().split())
    if a<b:
        print("No")
    elif d<b:
        print("No")
    elif c>=b:
        print("Yes")
    elif b-math.gcd(b,d)+(a%math.gcd(b,d))>c:
        print("No")
    else:
        print("Yes")

Solution (Python):
import math
N = int(input())
for i in range(N):
  A,B,C,D = map(int,input().split())
  if A<B: 
    print("No")
    continue
  if B>D: 
    print("No")
    continue
  if A%B > C: 
    print("No")
    continue
  cycle = D-B
  GCD = math.gcd(B,cycle)
  
  if GCD == 1 and B-1 > C:
    print("No")
    continue
  if B-GCD > C:
    print("No")
    continue
  print("Yes")

Solution (Python):
import math
t = int(input())
for _ in range(t):
    a, b, c, d = map(int, input().split())
    if a < b or b > d:  
        print("No")
        continue

    
    
    
    g = math.gcd(b, d)
    max_rem = b - g + a % g
    if max_rem > c:
        print("No")
    else:
        print("Yes")

Solution (Python):
from math import gcd

t = int(input())
for _ in range(t):
    a, b, c, d = map(int, input().split())
    if b > d or b > a:
        print("No")
    else:
        tmp = gcd(b, d)
        rem = a % tmp
        min_c = (c - rem) // tmp
        if min_c + 1 >= b // tmp:
            print("Yes")
        else:
            print("No")

Solution (Python):
from math import gcd
def solve():
  T = int(input())
  ans = ['No']*T
  for i in range(T):
    A,B,C,D = map(int, input().split())
    if A<B:
      continue
    now = A-(-(-(A-C)//B))*B
    if now<0:
      continue
    if D<B:
      continue
    if D%B==0:
      ans[i] = 'Yes'
      continue
    if C>=B:
      ans[i] = 'Yes'
      continue
    if B-gcd(D%B,B)>C:
      continue
    ans[i] = 'Yes'
  return ans
print(*solve(),sep='\n')

Solution (Python):
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
for _ in range(int(input())):
  a,b,c,d=map(int,input().split())
  if a<b or b>d:print("No");continue
  if c>=b:print("Yes");continue
  g=gcd(b,d)
  if (a%g+b-g)%b>c:print("No")
  else:print("Yes")

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

t=int(input())
abcd=[list(map(int,input().split())) for i in range(t)]

for i in range(t):
    a,b,c,d=abcd[i]
    if a<b:
        print("No")
    elif d<b:
        print("No")
    elif c>=b:
        print("Yes")
    elif b-math.gcd(b,d)+(a%math.gcd(b,d))>c:
        print("No")
    else:
        print("Yes")

Solution (Python):
import math
t=int(input())
for i in range(t):
 a,b,c,d=map(int,input().split())
 if b>a:print("No")
 elif b>d:print("No")
 elif c>=b:print("Yes")
 else:g=math.gcd(b,d);print("Yes"if c>=a%g+b-g else"No")

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def sub(a,b,c,d):
    x1 = a - max(0, (a - (c+1))//b) * b
    if d<b:
        ans = "No"
    elif a<b:
        ans = "No"
    elif d%b==0:
        if x1>=b:
            ans = "Yes"
        else:
            ans = "No"
    else:
        k = gcd(d,b)
        x2 = x1 - (x1 - (c+1))//k * k
        if x2>=b:
            ans = "Yes"
        else:
            ans = "No"
    return ans

t = int(input())
ans = []
for i in range(t):
    a,b,c,d = map(int, input().split())
    ans.append(sub(a,b,c,d))
write("\n".join(ans))

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def sub(a,b,c,d):
    x1 = a - (a - (c+1))//b * b
    if d<b:
        ans = "No"
    elif a<b:
        ans = "No"
    elif d%b==0:
        if x1>=b:
            ans = "Yes"
        else:
            ans = "No"
    else:
        k = gcd(d,b)
        x2 = x1 - (x1 - (c+1))//k * k
        if x2>=b:
            ans = "Yes"
        else:
            ans = "No"
    return ans

t = int(input())
ans = []
for i in range(t):
    a,b,c,d = map(int, input().split())
    ans.append(sub(a,b,c,d))
write("\n".join(ans))

Solution (Python):
from fractions import gcd
T = int(input())

for _ in range(T):
    a, b, c, d = map(int, input().split())
    if b > a or b > d:
        flg = False
    else:
        if b - 1 <= c:
            flg = True
        elif a % b > c:
            flg = False
        else:
            g = gcd(d, b)
            if (b - 1 - a % b) // g * g + a % b <= c: 
                flg = True
            else:
                flg = False

    if flg:
        print("Yes")
    else:
        print("No")

Solution (Python):
from fractions import gcd
t = int(input())
for _ in range(t):
    a, b, c, d = map(int, input().split())
    if b > d:
        print("No")
    elif a < b:
        print("No")
    elif c >= b:
        print("Yes")
    else:
        if c < b-gcd(b, d)+ a%gcd(b, d):
            print("No")
        else:
            print("Yes")

Solution (Python):
import math
import fractions



def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  
factinv = [1, 1]  
inv = [0, 1]  

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''












n = int(input())

for i in range(n):
    a,b,c,d = list(map(int, input().split()))
    if(b>d or a<b):
        print("No")
        continue
    G = fractions.gcd(b,d)
    minim = a%G
    if(b-G<=c and minim<=c):
        print("Yes")
    else:
        print("No")

Solution (Python):
from fractions import gcd
import sys
input = sys.stdin.readline

T = int(input())
for _ in range(T):
    A, B, C, D = map(int, input().split())
    if D < B or A < B:
        ans = 'No'
    elif C >= B:
        ans = 'Yes'
    else:
        g = gcd(B, D)
        lb, ub = -10**18, 10**18
        while ub - lb > 1:
            m = (lb + ub) // 2
            if A - g * m > C:
                lb = m
            else:
                ub = m
        if A - g * lb < B:
            ans = 'No'
        else:
            ans = 'Yes'
    print(ans)

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
T=int(input())
from fractions import gcd
for i in range(T):
    A,B,C,D=map(int,input().split())
    if A<B or D<B:
        print("No")
        continue
    if B<=C+1:
        print("Yes")
        continue
    if B==D:
        if A%B<=C:
            print("Yes")
        else:
            print("No")
        continue
    g=gcd(B,D-B)
    if (C-A%g)//g<(B-1-A%g)//g:
        print("No")
    else:
        print("Yes")

Solution (Python):
from fractions import gcd
T,*L = map(int, open(0).read().split())
for a,b,c,d in zip(*[iter(L)]*4):
  if b>d:
    print('No')
    continue
  if a<b:
    print('No')
    continue
  g = gcd(b,d)
  x = a-b
  M = ((c-x)//g+1)*g+x
  if M>=b:
    print('Yes')
  else:
    print('No')

Solution (Python):
from fractions import gcd
T,*L = map(int, open(0).read().split())
for a,b,c,d in zip(*[iter(L)]*4):
  if b>d:
    print('No')
    continue
  if a<b:
    print('No')
    continue
  if c>b:
    print('Yes')
    continue
  g = gcd(b,d)
  x = a-b
  M = ((c-x)//g+1)*g+x
  if M>=b:
    print('Yes')
  else:
    print('No')

Solution (Python):
from fractions import gcd
for i in range(int(input())):
    a,b,c,d=map(int,input().split())
    g=gcd(b,d)
    r=a%g
    if r>=b-d and c>=b-(g-r) and a>=b:
        print("Yes")
    else:
        print("No")

Solution (Python):
import sys
input = sys.stdin.readline

n = int(input())
C = [list(map(int,input().split())) for i in range(n)]

from fractions import gcd

for i in range(n):
    a = C[i][0]
    b = C[i][1]
    c = C[i][2]
    d = C[i][3]
    ng = 0

    e = 0  
    e0 = a - b
    e1 = ((c - a%b) // b) * b + a%b
    e = min(e0, e1)

    if e < 0 or b > d:
        ng = 1
    else:
        g = gcd(b, d)
        
        if c+1 <= b-1 and (c - e) // g < (b-1 - e) // g:
            ng = 1

    if ng == 1:
        print("No")
    else:
        print("Yes")

Solution (Python):
from fractions import gcd

T = int(input())

for i in range(T):
  A, B, C, D = map(int, input().split())
  if A < B or D < B:
    print('No')
  else:
    a = A % B
    if a > C:
      print('No')
    else:
      if C >= B:
        print('Yes')
      else:
        g = gcd(B, D)
        if B - g + A%g > C:
          print('No')
        else:
          print('Yes')

Solution (Python):
import fractions

T = int(input())

def solve(A, B, C, D):
    left = A
    if A < B:
        print('No')
        return
    if D < B:
        print('No')
        return
    if C >= B:
        print('Yes')
        return
    g = fractions.gcd(B, D)
    max_mod_b = B - g + (A % g)
    if max_mod_b > C:
        print('No')
    else:
        print('Yes')

for _ in range(T):
    A, B, C, D = map(int, input().split())
    solve(A, B, C, D)

Solution (Python):
T=int(input())
ABCD=[list(map(int,input().split())) for i in range(T)]
from fractions import gcd
def f(a):
    print(['No','Yes'][a])
for a,b,c,d in ABCD:
    if a<b:f(0)
    elif d<b:f(0)
    elif b<=c:f(1)
    else:
        g=gcd(b,d)
        h=a%b
        f(max(((b-h)//g*g+h)%b,b-g)<=c)

Solution (Python):
import fractions
t = int(input())
al = []
for i in range(t):
    a,b,c,d = map(int,input().split())
    if b > d:
        al.append("No")
    else:
        if b > a:
            al.append("No")
        else:
            if b-1 <= c:
                al.append("Yes")
            else:
                if a % b > c:
                    al.append("No")
                else:
                    yo = d%b
                    now = a%b 
                    if yo == 0:
                        al.append("Yes")
                    else:
                        g = fractions.gcd(b,yo)
                        
                        if c >= b-g+a%g:
                            al.append("Yes")
                        else:
                            al.append("No")
for i in al:
    print(i)

Solution (Python):
t = int(input())

import fractions

for _ in range(t):
    a,b,c,d = map(int, input().split())

    if(b > d)|(a < b):
        print('No')
        continue

    if(b <= c):
        print('Yes')
        continue

    c1 = a - (1+(a-c-1)//b)*b
    if(c1 < 0):
        print('No')
        continue

    mod = fractions.gcd(b,d)
    red = c1 % mod

    for i in [0,1]:
        tmp = ((c//mod) + i)*mod + red
        if(c < tmp < b):
            print('No')
            break

        if(i==1):
            print('Yes')

Solution (Python):
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))



import fractions

T = I()
A,B,C,D = LIR(T,4)

for i in range(T):
    if A[i] < B[i]:
        print('No')
        continue

    g = fractions.gcd(B[i],D[i])

    
    x = (A[i]%B[i])//g
    min_ = (A[i]%B[i]) - x*g

    x = (B[i]-1-(A[i]%B[i])) // g
    max_ = (A[i]%B[i]) + x*g

    if max_ > C[i] or min_ < B[i]-D[i]:
        print('No')
    else:
        print('Yes')

Solution (Python):

from fractions import gcd
def judge(A,B,C,D):
    """
    在庫数をXとする。
    C < X < B のときFalse
    p,qを0以上の整数とすると、
    X = A + D * p - B * q 
    X = A % G + k * G

    C + 1 <= X
    -> k = ceil((C + 1 - A % G) / G)
    """

    if A < B: return False
    if D < B: return False
    if C >= B: return True
    
    G = gcd(B, D)
    k = (C - (A % G) + G) // G
    return False if ((A % G + k * G) < B) else True

T = int(input())
for _ in range(T):
    A,B,C,D = map(int, input().split())
    if judge(A,B,C,D): print('Yes')
    else: print('No')

Solution (Python):

from fractions import gcd
def judge(A,B,C,D):
    if A < B: return False
    if D < B: return False
    if C >= B: return True
    
    g = gcd(B, D)

    return False if ((B - g + (A % g)) > C) else True

T = int(input())
for _ in range(T):
    A,B,C,D = map(int, input().split())
    if judge(A,B,C,D): print('Yes')
    else: print('No')

Solution (Python):
T = int(input())

def gcd(a, b):
  if a < b:
    a, b = b, a
  if b == 0:
    return 0
  while a % b:
    a, b = b, a % b
  return b

while T:
  T -= 1
  
  A, B, C, D = map(int, input().split())
  
  if B > A or B > D:
    print("No")
  else:
    p = A - (A - C + B - 1) // B * B
    r = D % B
    g = gcd(r, B - r)
    if p < 0:
      print("No")
    elif r == 0 or (C - r - p + g) // g * g + p - B + r >= 0:
      print("Yes")
    else:
      print("No")

Solution (Python):
from fractions import gcd
def main():
    T=int(input())
    for _ in range(T):
        A,B,C,D=map(int, input().split())
        ans=True
        if B>D or B>A:
            ans=False
        elif B<=C:
            pass
        else:
            i=A%B
            if C<i:
                ans=False
            g=gcd(B,D)
            if g and not ((C-i)//g*g+i<=C and B<=(C-i)//g*g+i+g):
                ans=False
        print("YNeos"[not ans::2])

if __name__ == "__main__":
    main()

Solution (Python):
from fractions import gcd
T, *L = map(int, open(0).read().split())
for a,b,c,d in zip(*[iter(L)]*4):
  if b>d:
    print('No')
  elif b>a:
    print('No')
  elif c>=b:
    print('Yes')
  elif b==d:
    if a%b<c:
      print('Yes')
    else:
      print('No')
  else:
    m = d%b
    n = a%b
    g = gcd(b,d)
    if b-g+(a%g)>c:
      print('No')
    else:
      print('Yes')

Solution (Python):
import sys
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

T = ir()

def check(a, b, c, d):
    if a < b or d < b:
        answer = 'No'
    
    elif c >= b:
        answer = 'Yes'
    else:
        a %= b; d %= b
        
        g = gcd(b, d)
        if b - g + (a % g) > c:
            answer = 'No'
        else:
            answer = 'Yes'
    print(answer)

for _ in range(T):
    check(*lr())

Solution (Python):
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

import fractions
t = inn()
for i in range(t):
    a,b,c,d = inm()
    if a<b or d<b:
        print('No')
    else:
        g = fractions.gcd(b,d)
        r = a%g
        q = c%g
        p = c-q+r
        if p<=c:
            p += g
        
        if p>=b:
            print('Yes')
        else:
            print('No')

Solution (Python):

t = int(input())
for _ in range(t):
  a,b,c,d = map(int,input().split())
  if d - b < 0:
    print('No')
    continue
  if a - b < 0:
    print('No')
    continue
  big = int(b)
  sml = int(d)
  while sml != 0:
    big,sml = sml,big%sml
  gcd = big
  r = (a-c-1) % gcd + 1
  if r + c >= b:
    print('Yes')
  else:
    print('No')

Solution (Python):
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy

T=int(input())
ABCD=[list(map(int,input().split())) for i in range(T)]
for A,B,C,D in ABCD:
    if B>D or A<B:
        print("No")
    elif B==D:
        if A%B<=C:
            print("Yes")
        else:
            print("No")
    else:
        E=B-C-1
        if E>0:
            F=D-B
            if E>F:
                print("No")
            else:
                _gcd=gcd(F,B)
                st=(A-B)%_gcd
                
                
                if B-_gcd+A%_gcd>C:
                    print("No")
                else:
                    print("Yes")
        else:
            print("Yes")

Solution (Python):
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy

T=int(input())
ABCD=[list(map(int,input().split())) for i in range(T)]
for A,B,C,D in ABCD:
    if B>D or A<B:
        print("No")
    elif C>=B:
        print("Yes")
    else:
        F=D-B
        _gcd=gcd(D,B)
        st=(A-B)%_gcd
        
        
        if B-_gcd+A%_gcd>C:
            print("No")
        else:
            print("Yes")

Solution (Python):
from fractions import gcd
t = int(input())
for _ in range(t):
  a, b, c, d = map(int, input().split())
  if a - b < 0:
    print("No")
    continue
  if b > d:
    print("No")
    continue
  g = gcd(b, d)
  s = a + (c - a) // b * b
  if s < 0:
    print("No")
    continue
  
  if (((b - s - 1) // g) * g + s) % b > c: print("No")
  else: print("Yes")