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 sys
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            
            ok = mid
        else:
            
            ng = mid
    return ok

def bisearch_max(mn, mx, func):
    """ 条件を満たす最大値を見つける二分探索 """

    ok = mn
    ng = mx
    while ok+1 < ng:
        mid = (ok+ng) // 2
        if func(mid):
            
            ok = mid
        else:
            
            ng = mid
    return ok

for _ in range(INT()):
    a, b, c, d = MAP()

    
    if a < b or d < b:
        No()
        continue
    
    
    g = gcd(b, d)

    
    mn = bisearch_min(-INF, INF, lambda m: a%g + g*m > c)
    mx = bisearch_max(-INF, INF, lambda m: a%g + g*m < b)
    if mn > mx:
        Yes()
    else:
        No()

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

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

Solution (Python):
def examA():
    N = I()
    A = LI()
    ans = 0
    for i in range(N-1):
        if A[i+1]==A[i]:
            A[i+1] = 101
            ans +=1
    print(ans)
    return

def gcd(x,y):
    if y==0:
        return x
    while(y!=0):
        x, y = y,x%y
    return x
def examB():
    T = I()
    for i in range(T):
        ans = "Yes"
        A, B, C, D = LI()
        if A<B:
            ans = "No"
        elif D<B:
            ans = "No"
        elif C>=B:
            print(ans)
            continue
        elif B-C>gcd(D,B):
            ans = "No"
        if (A % B) > C:
            ans = "No"
        print(ans)
    return

def examC():
    N = I()
    S = SI()
    d1 = defaultdict(int)
    d2 = defaultdict(int)
    loop = 2**N
    for i in range(loop):
        curR = ""; curB = ""
        curR2 = ""; curB2 = ""
        for j in range(N):
            if i&(1<<j)==(1<<j):
                curR +=S[j]
                curR2 +=S[j+N]
            else:
                curB +=S[j]
                curB2 +=S[j+N]
        d1[(curR,curB)] +=1
        d2[(curR2,curB2)] +=1
    ans = 0
    for key,i in d1.items():
        cur = i*d2[(key[1][::-1],key[0][::-1])]
        ans +=cur
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examB()

Solution (Python):
from fractions import gcd
from functools import reduce
def gcds(*numbers):
  return reduce(gcd, numbers)
n = int(input())
for i in range(n):
  a,b,c,d = map(int,input().split())
  x = gcds(a,b,c,d)
  if x != 1:
    a = a//x
    b = b//x
    c = c//x
    d = d//x
  if b>d or a<b:
    print("No")
  elif c>=b-1:
    print("Yes")
  elif gcd(b,d) != 1:
    y = gcd(b,d)
    if b-c<y and c%y >= a%y:
        print("Yes")
    else:
      print("No")
  else:
    print("No")

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

T = int(input())
for _ in range(T):
    A, B, C, D = map(int, input().split())
    if D < B or A < B:
        print("No")
        continue
    x = A - (A-C+B-1) // B * B
    g = gcd(B, D)
    l = (C - x) % g
    if C - B + g - l >= 0:
        print("Yes")
    else:
        print("No")

Solution (Python):
import fractions

T = int(input())

for i in range(T):

    a,b,c,d = map(int,input().split())

    if a < b or d < b:
        print ("No")
        continue

    elif b-c < 2:
        print ("Yes")
        continue

    elif (((a-b) % fractions.gcd(b,d-b)) + b - fractions.gcd(b,d-b) > c and ((a-b) % fractions.gcd(b,d-b)) + b - fractions.gcd(b,d-b) < b):
        print ("No")

    else:
        print ("Yes")

Solution (Python):
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    else:
        return gcd(y,x%y)

T=int(input())
for _ in range(T):
    A,B,C,D=map(int,input().split())
    if D<B:
        print("No")
        continue
    if A<B:
        print("No")
        continue
    if C>=B:
        print("Yes")
        continue
    a=A%B
    d=D%B
    g=gcd(d,B)
    k=(C-a)//g
    if a+(k+1)*g>=B:
        print("Yes")
    else:
        print("No")

Solution (Python):


















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


def judge(A, B, C, D):
    """A:初期値,B:減少量,C以下で増加,D増加量"""
    if (B > A) or (B > D):
        
        
        return False

    if B <= C:
        
        
        return True

    
    
    g = gcd(B, D)
    a = A % g
    return a - g < C + 1 - B
    
    
    


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

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from fractions import gcd
def resolve():
    for _ 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)
        a%=g
        a-=g
        u=(c-a)//g+1
        if(a+u*g>=b):
            print("Yes")
        else:
            print("No")
resolve()

Solution (Python):
from fractions import gcd
for _ in range(int(input())):
 a,b,c,d=list(map(int,input().split()))
 k,p=b*max((a-c-1)//b+1,1),0
 if d<b or a<k:p=1
 elif b<c+2:p=0
 elif b-c>gcd(b,d):p=1
 print("YNeos"[p::2])

Solution (Python):
def main():
    from fractions import gcd
    n=int(input())
    for _ in range(n):
        a,b,c,d=list(map(int,input().split()))
        if a<b or b>d:
            print("No")
            continue
        k=(a-c-1)//b+1
        e=a-b*k
        if e<0:
            print("No")
            continue
        if b<=c+1 and b<=d:
            print("Yes")
            continue
        g=gcd(b,d)
        if b-c>g:
            print("No")
        else:
            print("Yes")
main()

Solution (Python):
def gcd(x, y):
	while y:
		x, y = y, x % y
	return x

_, *Q = map(int, open(0).read().split())
for a, b, c, d in zip(*[iter(Q)] * 4):
	if a < b or d < b:
		print("No")
		continue
	if c >= b:
		print("Yes")
		continue
	a %= b
	g = gcd(b, d)
	
	if b - g + a - g * (a // g) > c:
		print("No")
	else:
		print("Yes")

Solution (Python):
from fractions import gcd
_, *Q = map(int, open(0).read().split())
for a, b, c, d in zip(*[iter(Q)] * 4):
	if a < b or d < b:
		print("No")
		continue
	if c >= b:
		print("Yes")
		continue
	a %= b
	g = gcd(b, d)
	
	if b - g + a - g * (a // g) > c:
		print("No")
	else:
		print("Yes")

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

Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]

def solve(A, B, C, D):
    if A < B or D < B:
        return False
    if C < B-1:
        if D%B != 0:
            cycle = gcd(D, B)
            if C < B-cycle:
                return False
            if A%cycle < (C+1)%cycle:
                return True
            else:
                return False
        else:
            if A%B <= C:
                return True
            else:
                return False
    else:
        return True

for A, B, C, D in Query:
    ans = "Yes" if solve(A, B, C, D) else "No"
    print(ans)

Solution (Python):
T = int(input())
ABCD = [[int(i) for i in input().split()] for _ in range(T)]

def gcd(a, b) :
    a, b = max(a, b), min(a, b)
    while b != 0 :
        a, b = b, a % b
    return a

def solve(A, B, C, D) :
    if B > A or B > D :
        return 'No'
        
    a0 = A % B
    d = gcd(B, D)
    if a0 + ((C - a0) // d + 1) * d >= B :
        return 'Yes'
        
    return 'No'

for A, B, C, D in ABCD :
    print(solve(A, B, C, D))

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

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

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

t = int(input())
for i in range(t):
    a, b, c, d = map(int, input().split())
    if solve(a, b, c, d):
        print("Yes")
    else:
        print("No")

Solution (Python):
from fractions import*
_,*t=open(0)
for t in t:a,b,c,d=map(int,t.split());print('YNeos'[b>min(a,d)or~a%gcd(b,d)-b<~c::2])

Solution (Python):
from fractions import*;_,*t=open(0)
for t in t:a,b,c,d=map(int,t.split());print('YNeos'[b>min(a,d)or~a%gcd(b,d)-b<~c::2])

Solution (Python):
from fractions import*;_,*t=open(0)
for t in t:a,b,c,d=map(int,t.split());print('YNeos'[b>min(a,d)or~(~a%gcd(b,d))+b>c::2])

Solution (Python):
from fractions import*
_,*t=open(0)
for t in t:
  a,b,c,d=map(int,t.split())
  print('YNeos'[b>min(a,d)or~(~a%gcd(b,d))+b>c::2])

Solution (Python):
from fractions import*;exec("a,b,c,d=map(int,input().split());g=gcd(b,d);print('YNeos'[b>min(a,d)or b-g+a%g>c::2]);"*int(input()))

Solution (Python):
from fractions import*
_,*t=open(0)
for t in t:
  a,b,c,d=map(int,t.split())
  g=gcd(b,d)
  print('YNeos'[b>min(a,d)or b-g+a%g>c::2])

Solution (Python):
from fractions import*
_,*t=open(0)
for t in t:
  a,b,c,d=map(int,t.split())
  g=gcd(b,d)
  print('YNeos'[b>min(a,d)or b-g+a%g>c::2])

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

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

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

T, *L = map(int, open(0).read().split())

for t in zip(*[iter(L)] * 4):
    print(("No", "Yes")[solve(*t)])

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

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

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

T, *L = map(int, open(0).read().split())

for t in zip(*[iter(L)] * 4):
    print("Yes" if solve(*t) else "No")

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

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

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

T, *L = map(int, open(0).read().split())

print("\n".join("Yes" if solve(*t) else "No" for t in  zip(*[iter(L)] * 4)))

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

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

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

T, *L = map(int, open(0).read().split())

for t in zip(*[iter(L)] * 4):
    if solve(*t):
        print("Yes")
    else:
        print("No")

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

T, *L = map(int, open(0).read().split())

for a, b, c, d in zip(*[iter(L)] * 4):

    if a < b or d < b:
        flag = False
    elif b < c:
        flag = True
    else:
        g = gcd(b, d)
        flag = (b + a % g - g) <= c

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

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

T, *L = map(int, open(0).read().split())

for a, b, c, d in zip(*[iter(L)] * 4):

    if a < b or d < b:
        flag = False
    elif c >= b - 1:
        flag = True
    else:
        g = gcd(b, d)
        flag = (b + a % g - g) <= c

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

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

T = int(input())

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

    if a < b or d < b:
        flag = False
    elif c >= b - 1:
        flag = True
    else:
        g = gcd(b, d)
        flag = (b + a % g - g) <= c

    if flag:
        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 a < b or d < b:
        flag = False
    elif c >= b - 1:
        flag =  True
    else:
        g = gcd(b, d)
        flag = (b + a % g - g) <= c

    if flag:
        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 a < b or d < b:
        flag = False
    elif c >= b - 1:
        flag =  True
    else:
        g = gcd(b, d)
        flag = (b + a % g - g) <= c

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

Solution (Python):
from fractions import gcd

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

    if c >= b - 1:
        return True

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

T, *L = map(int, open(0).read().split())

for t in zip(*[iter(L)] * 4):
    if solve(*t):
        print("Yes")
    else:
        print("No")

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def gcd(x, y):
    while y:
        x, y = y, x % y
    return x


t = I()
for i in range(t):
    a, b, c, d = LI()
    g = gcd(b, d)
    if b > d or a < b:
        print('No')
    elif c >= b - 1:
        print('Yes')
    elif (a - (b - 1) - 1) // g != (a - (c + 1)) // g:
        print('No')
    else:
        print('Yes')

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

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

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

    if A < B:
        ans.append('No')
        continue

    if B > D:
        ans.append('No')
        continue

    if C >= B:
        ans.append('Yes')
        continue

    
    G = gcd(D, B)
    maxMod = B - G + A % G
    if C < maxMod:
        ans.append('No')
    else:
        ans.append('Yes')

print(*ans, sep='\n')

Solution (Python):
from fractions import gcd
n = int(raw_input())
lim = 10**19
for i in xrange(n):
	a, b, c, d = map(int, raw_input().split())
	if a < b or d < b:
		print 'No'
	else:
		
		e = c - b + 1
		g = gcd(b, d)
		dist = abs(a % g) - abs(e % g) + g
		dist %= g
		e += dist
		if e < 0 or e > c - b + d:
			print 'No'
		else:
			print 'Yes'

Solution (Python):
import os
import sys
from fractions import gcd

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

T = int(sys.stdin.readline())
ABCD = [list(map(int, sys.stdin.readline().split())) for _ in range(T)]


def solve(A, B, C, D):
    if B > D:
        return False
    if A < B:
        return False
    if C >= B:
        return True
    
    
    p = gcd(D, B)  
    if p < B - C:
        return False
    if (B - A - 1) % p < B - C - 1:
        return False
    return True


ans = []
for a, b, c, d in ABCD:
    ans.append('Yes' if solve(a, b, c, d) else 'No')
print(*ans, sep='\n')

Solution (Python):
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

T = int(sys.stdin.readline())
ABCD = [list(map(int, sys.stdin.readline().split())) for _ in range(T)]


def solve(A, B, C, D):
    if B > D:
        return False
    if A < B:
        return False
    if C >= B:
        return True
    
    
    p = gcd(D, B)  
    if p < B - C:
        return False
    if (B - A - 1) % p < B - C - 1:
        return False
    return True


ans = []
for a, b, c, d in ABCD:
    ans.append('Yes' if solve(a, b, c, d) else 'No')
print(*ans, sep='\n')

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

from fractions import gcd

T = int(input())
ABCD = [[int(x) for x in input().split()] for _ in range(T)]

def F(A,B,C,D):
    if D<B:
        return False
    if A<B:
        return False
    g = gcd(D,B)
    
    diff = A%g
    A -= diff
    C -= diff
    C -= C%g
    A //= g; B //= g; C //= g; D //= g
    
    
    
    return C+1>=B

print('\n'.join('Yes' if F(a,b,c,d) else 'No' for a,b,c,d in ABCD))

Solution (Python):

from fractions import gcd

def solve(initial, burn, check, resupply):
    if burn > initial or burn > resupply:
        return False
    if check >= burn:
        return True

    x = initial % burn
    g = gcd(resupply, burn)
    
    
    k = (burn - x) // g
    if k * g + x == burn: k -= 1
    return x + k * g <= check

for _ in xrange(int(raw_input())):
    print "Yes" if solve(*map(int, raw_input().split())) else "No"

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

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

n=int(input())
for _ in range(n):
  a,b,c,d=map(int,input().split())
  if a<b or a%b>c or b>d:
    print('No')
  else:
    if b==d:
      print('Yes')
    elif a%b+d==a:
      print('Yes')
    else:
      if c+gcd(b,d)>=b:
        print('Yes')
      else:
        print('No')

Solution (Python):
import fractions

T = int(input())
for i in range(T):
    A, B, C, D = map(int, input().split())
    if A < B:
        print('No')
        continue
    if B > D:
        print('No')
        continue
    if C >= B - 1:
        print('Yes')
        continue
    A = A % B
    D = D % B
    BD = fractions.gcd(B, D)
    A_max = A + BD * ((B - 1 - A) // BD)
    if A_max > C:
        print('No')
    else:
        print('Yes')

Solution (Python):
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    return gcd(b, a % b)

def check(A, B, C, D):
    if A < B:
        return False
    if C < A % B:
        return False
    if D < B:
        return False
    x = gcd(B, D)
    return B <= C + x

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


if __name__ == "__main__":
    main()

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


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


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')
    else:
        g = gcd(b, d)
        if b - g + a % g > c:
            print('No')
        else:
            print('Yes')

Solution (Python):
gcd = lambda x,y: x if y==0 else gcd(y,x%y)

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

Solution (Python):
import fractions as f
for i in range(int(input())):
 a,b,c,d=map(int,input().split())
 g=f.gcd(b,d)
 print("No" if a<b or b>d or a-((a-b)//g+1)*g>c else "Yes")

Solution (Python):
import fractions as f
for i in range(int(input())):
 a,b,c,d=list(map(int,input().split()))
 g=f.gcd(b,d)
 if a<b or b>d or a-((a-b)//g+1)*g>c:
  print("No")
 else:
  print("Yes")

Solution (Python):
T = int(input())
ABCD = [list(map(int, input().split())) for _ in range(T)]

from fractions import gcd

for a,b,c,d in ABCD:
  if a<b:
    print('No')
    continue
    
  l = gcd(b,d)
  a = a % b
  if (a + ((b-a-1)//l)*l) <= c and (a - (a//l)*l)+d>=b:
    print('Yes')
  else:
    print('No')

Solution (Python):
from fractions import gcd

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

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

Solution (Python):
t = int(input())
query = [tuple(map(int, input().split())) for _ in range(t)]
def gcd(x, y):
    if y == 0: return x
    return gcd(y, x % y)
for a, b, c, d in query:
    g = gcd(b, d)
    r = a % g
    m = ((c - r)//g + 1) * g
    if b <= m and b <= a and b <= d: print('Yes')
    else: print('No')

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

def gcd (a: int,b: int) -> int:
    if a < b: a,b = b,a
    return a if b == 0 else gcd(b,a%b)
def lcm (a: int,b: int) -> int:
    return a // gcd(a,b) * b


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

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


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

def solve(T: int, A: "List[int]", B: "List[int]", C: "List[int]", D: "List[int]"):
    for i in range(T):
        a, b, c, d = A[i], B[i], C[i], D[i]
        if a<b or b>d:
            print('No')
            continue
        x = (c-a+1)%b
        g = gcd(b, d)
        print('No' if -(-x//g*g) - x + c+1 < b else 'Yes')


    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    T = int(next(tokens))  
    A = [int()] * (T)  
    B = [int()] * (T)  
    C = [int()] * (T)  
    D = [int()] * (T)  
    for i in range(T):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
        D[i] = int(next(tokens))
    solve(T, A, B, C, D)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
from fractions import gcd
def f(a,b,c,d):
    if a<b:
        return 0
    if b>d:
        return 0
    if b<=c:
        return 1
    x=a%b
    g=gcd(b,d)
    if c>=b-g+(x%g):
        return 1
    else:
        return 0
T=int(input())
X=[[int(i) for i in input().split()] for i in range(T)]
for a,b,c,d in X:
    s=f(a,b,c,d)
    if s:
        print('Yes')
    else:
        print('No')

Solution (Python):
import sys
input = sys.stdin.readline
from fractions import gcd
def f(a,b,c,d):
    if a<b:
        return 0
    if b>d:
        return 0
    if b-1<=c:
        return 1
    x=a%b
    
    if b==d:
        if c<x:
            return 0
        elif c>=x:
            return 1
    
    if c<x:
        return 0
    e=(d-b)%b
    d1=gcd(e,b)
    q=(c+1-x)//d1
    q1=(b-1-x)//d1
    
    if q<q1:
        return 0
    if (c+1-x)%d1==0:
        return 0
    return 1
T=int(input())
X=[[int(i) for i in input().split()] for i in range(T)]
for a,b,c,d in X:
    s=f(a,b,c,d)
    if s:
        print('Yes')
    else:
        print('No')

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

T = int(input())

for _ 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')
    elif A % B > C:
        print('No')
    else:
        s = A % B
        g = gcd(B, D)
        if s + (B-1-s)//g*g > C:
            print('No')
        else:
            print('Yes')

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

T = int(input())

for _ 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 = gcd(B, D)
        if B - g + (A % g) > C:
            print('No')
        else:
            print('Yes')

Solution (Python):
def Yes():
  print("Yes")
def No():
  print("No")

def gcd(x, y):
  b = max(x, y)
  s = min(x, y)
  r = b % s
  while r != 0:
    b = s
    s = r
    r = b % s
  return s

def lcm(x, y):
  return (x * y) // gcd(x,y)

def main():
  T = int(input())
  AD = [list(map(int, input().split())) for i in range(T)]

  for i in AD:
    A = i[0]
    B = i[1]
    C = i[2]
    D = i[3]
    if A < B:
      No()
      continue
    if B > D:
      No()
      continue
    add = D - B
    d = gcd(B, D)
    
    C += 1
    t = C % d
    k = A % d
    if k == t:
      LD = C
    elif k > t:
      LD = C + k - t
    else:
      LD = C + d - t + k
    if LD < B:
      No()
    else:
      Yes()

main()

Solution (Python):
def g(a, b):
    if a%b == 0: return b
    return g(b, a%b)

def f(a, b, c, d):
    yes = "Yes"
    no  = "No"
    if a<b or d<b: return no
    if c>=b or a<=c: return yes
    if (a-c)%b>0 and (a-c)%b<b-c: return no
    e = d%b
    if e==0 or b-c==1: return yes
    if e==1: return no
    h = g(b, e)
    if h<b-c: return no
    if (a-c)%h>0 and (a-c)%h<b-c: return no
    return yes

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

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

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

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

    g = gcd(d, b)
    print("Yes" if b - g + a % g <= c else "No")

Solution (Python):
T = int(input())
ABCD = [[int(_) for _ in input().split()] for _ in range(T)]


def gcd(x, y):
    if x < y:
        return gcd(y, x)
    elif x % y == 0:
        return y
    else:
        return gcd(y, x % y)


for a, b, c, d in ABCD:
    if a < b or d < b:
        print('No')
    else:
        g = gcd(b, d)
        x = g * (c // g) + (a % g)
        if x <= c:
            x += g
        if x >= b:
            print('Yes')
        else:
            print('No')

Solution (Python):
from fractions import gcd
T=int(input())
for i in range(T):
  A,B,C,D=map(int,input().split())
  if B<=A and B<=D:
    if B<=C:
      print("Yes")
    else:
      G=gcd(B,D)
      a=A%G
      t=(C-a)//G+1
      if B>t*G+a:
        print("No")
      else:
        print("Yes")
  else:
    print("No")

Solution (Python):
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
def inpl(): return [int(i) for i in input().split()]
T = int(input())
for _ in range(T):
    A, B, C, D = inpl()
    if A < B or B > D:
        print('No')
        continue
    if C >= B:
        print('Yes')
        continue
    gcdbd = gcd(B, D)
    if (1+(C-A%B)//gcdbd)*gcdbd+A%B >= B:
        print('Yes')
    else:
        print('No')

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