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):
from math import floor
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
T = int(input())
for i in range(T):
    A,B,C,D = map(int,input().split())
    if B > D or B > A:
        print("No")
    else:
        if A%B>C:
            print("No")
        else:
            d = gcd(B,D%B)
            r = (A%B)%d
            if B - d + r > C:
                print("No")
            else:
                print("Yes")

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

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

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

Solution (Python):
from fractions import gcd

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

for a, b, c, d in abcdt:
  if a < b:
    print('No')
  elif d < b:
    print('No')
  else:
    if d - b != 0:
      g = gcd(b, d - b)
    else:
      g = b
    if (a - c - 1) // g >= - ((-(a - b + 1)) // g):
      print('No')
    else:
      print('Yes')

Solution (Python):

from fractions import gcd

def ng(a, b, c, add):
    return 0 < (b-a)%add < (b-c)

def solve():
    a, b, c, d = map(int, input().split())
    
    if d < b or a < b:
        return 'No'
    if c > b:
        return 'Yes'
    a %= b
    if a > c:
        return 'No'

    if d-b == 0:
        return 'Yes'

    if gcd(b, d-b) < b-c:
        return 'No'
    else:
        return 'Yes'
    
    

    
    
    
    
    
    
    
T = int(input())
for _ in range(T):
    print(solve())

Solution (Python):
def main():
    import math

    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(input())
    ABCD = [list(map(int, input().split())) for i in range(N)]
    for A,B,C,D in ABCD:
        
        if A < B or D < B:
            print("No")
            continue

        A %= B
        
        if C < A:
            print("No")
            continue
        if B == D:
            print("Yes")
            continue

        flag = True
        
        if (B-A-1)%(gcd(D,B)) <= (B-1)-(C+1):
            flag = False
        
        print("Yes" if flag else "No")


if __name__ == '__main__':
    main()

Solution (Python):
import fractions
N = int(input())
x = []
for i in range(N):
    a1,b1,c1,d1=[int(i) for i in input().split()]
    x.append([a1,b1,c1,d1])
for i in range(N):
  y = x[i]
  if y[0] < y[1]:
    print("No")
  elif y[1] > y[3]:
    print("No")
  elif y[1] > y[2]:
    ama = y[0] % y[1]
    mo = y[3] %  y[1]
    if mo == 0:
      if ama<= y[2]:
        print("Yes")
      else:
          print("No")
    elif mo <= y[1]-y[2]-1:
      print("No")
    else:
        to = y[1] % mo
        if to == 0:
          if ama<= y[2]:
            print("Yes")
          else:
              print("No")
        else:
          are = fractions.gcd(to, y[1])
          if are <= y[1]-y[2]-1:
            print("No")
          else:
            print("Yes")
          
  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 (A < B) or (D < B):
        print('No')
        continue
    elif (C+1 >= B):
        print('Yes')
        continue
    else:
        s_res = A % B
        s_k = int((C + 1 - s_res - 0.1) // B + 1)
        X = gcd(B, (D%B))
        if X == 1:
            print('No')
            continue
        else:
            s_0 = s_k * B + s_res
            if (s_0 - (C+1)) % X > (B-C-2):
                print('Yes')
            else:
                print('No')

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

ABCD = []
for i in range(T):
    a,b,c,d = map(int,input().split())
    ABCD.append((a,b,c,d))

for abcd in ABCD:
    a,b,c,d = abcd
    
    if a < b:
        print("No")
    
    elif d < b:
        print("No")
    
    elif c >= b:
        print("Yes")
    else:
        
        e = a%b
        f = d%b
        list = [a]
        if f==0:
            if c<e<b:
                print("No")
            else:
                print("Yes") 
        else:
            cnt = 0
            while cnt < 100:
                g = ((c-e)//f+1)*f+e
                if g < b:
                    print("No")
                    cnt += 10000
                else:
                    if g in list:
                        print("Yes")
                        cnt += 10000
                    else:
                        list.append(g)
                        a = g
                        e = a%b
                        f = d%b
                        cnt += 1

Solution (Python):
from fractions import gcd

def solve(a, b, c, d):
    if d < b: return False
    g = gcd(d, b)
    a, ar = divmod(a, g)
    c, cr = divmod(c, g)
    d /= g
    b /= g
    if ar > cr: c -= 1
    if a < b: return False
    return c >= b - 1

for cas in xrange(input()):
    print 'Yes' if solve(*map(int, raw_input().split())) else 'No'

Solution (Python):
from fractions import gcd
T=input()
def check(a,b,c,d):
	a-=b
	if a<0: return 0
	if d<b: return 0
	if d>=b:
		if c>=b-1: return 1
		else:
			d=gcd(b,d)
			a%=d
			l=c+d-a
			r=b+d-a-1

			if l/d<r/d:
				return 0
			else:
				return 1
			
for i in xrange(T):
	a,b,c,d=map(int,raw_input().split())
	if check(a,b,c,d):
		print "Yes"
	else:
		print "No"

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

T = int(raw_input())

for i in range(T):
    A,B,C,D = map(int,raw_input().split())
    if A<B:
        print 'No'
    elif B>D:
        print 'No'
    elif C>=B:
        print 'Yes'
    else:
        if A%B>C:
            print 'No'
        elif D%B==0:
            print 'Yes'
        elif gcd(D%B,B)>=B-C and ( (B-A%B)%(D%B)>=B-C or (B-A%B)%(D%B)==0):
            print 'Yes'
        else:
            print 'No'

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

t=int(input())
for sdghsoewrgoijof in range(t):
    s=input().split()
    a,b,c,d=int(s[0]),int(s[1]),int(s[2]),int(s[3])
    if a<b or d<b:
        print("No")
        continue
    if a==b:
        if d<b:
            print("No")
            continue
        elif d==b:
            print("Yes")
            continue
        else:
            a=d
    if a%b>c:
        print("No")
        continue
    if d%b==0:
        print("Yes")
    else:
        g=gcd(b,d)
        if b+(a%g)-g>c:
            print("No")
        else:
            print("Yes")

Solution (Python):
import math

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

for i in range(t):
    if abcd[i][0] < abcd[i][1]:
        print("No")
    elif abcd[i][1] > abcd[i][3]:
        print("No")
    elif abcd[i][3] % abcd[i][1] == 0:
        if abcd[i][0] % abcd[i][1] > abcd[i][2]:
            print("No")
        else:
            print("Yes")
    else:
        big, small = abcd[i][1], abcd[i][3]
        while big % small:
            big, small = small, big % small
        gcd = small
        if abcd[i][1] - gcd <= abcd[i][2]:
            print("Yes")
        else:
            print("No")

Solution (Python):



import sys
from fractions import gcd

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

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


def main():
    T = rl(int)
    for t in xrange(1, T+1):
        A, B, C, D = srl(int)
        print "Yes" if solve(A, B, C, D) else "No"

if __name__ == '__main__':
    main()

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

for _ in range(T):
    A, B, C, D = map(int, input().split())
    
    if A < B:
        print("No")
        continue
    
    if C < A%B < B:
        print("No")
        continue
    
    if D % B == 0:
        print("Yes")
        continue
    
    if D < B:
        print("No")
        continue
    
    if C+(gcd(B,D)) < B:
        print("No")
        continue
    
    print("Yes")

Solution (Python):


import fractions

def isok(a,b,c,d):
    if a < b or b > d:
        print('No')
        return
    g= fractions.gcd(d, b)
    r=((c-a%g)//g)*g+a%g

    if r+g-b < 0:
        print('No')
    else:
        print('Yes')
    

T=int(input())

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

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

def check(a,b,c,d):
    if b > d or a < b:
        print("No")
        return
    elif c >= b:
        print("Yes")
        return
    def_a = a % b
    a = def_a
    while True:
        a = (a + d) % b
        if a > c:
            print("No")
            return
        g = fractions.gcd(b,d)
        f = (b -a) // g
        if (b - a) % g == 0:
            f -= 1
        if g == 0 or c >= a + f * g:
            print("Yes")
            return
        print("No")
        return

for abcd in ABCD:
    check(abcd[0],abcd[1],abcd[2],abcd[3])

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

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

  cnt=gcd(b,d)
  mi=a-b
  ma=a-c
  if ma-mi > cnt :
    return True
  elif ma-mi <= 1:
    return False
  elif (mi+cnt)//cnt*cnt < ma:
    return True
  else:
    return False

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

Solution (Python):
import sys

sys.setrecursionlimit(100000)

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

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

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

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

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

    diff = d % b
    if diff == 0:
        if a % b <= c:
            print("Yes")
            continue
        else:
            print("No")
            continue

    g = gcd(b, diff)

    init_mod = c % b

    base_mod = init_mod % g
    if b + base_mod - g > c:
        print("No")
    else:
        print("Yes")

Solution (Python):
from fractions import gcd

T = int(input())
qs = [tuple(map(int,input().split())) for i in range(T)]

def solve(q):
    a,b,c,d = q
    if b > d: return False
    if a < b: return False
    a %= b
    if a > c: return False
    if b == d: return True
    g = gcd(b, d)
    return b-g <= c

for q in qs:
    print('Yes' if solve(q) else 'No')

Solution (Python):


import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq





def gcd(a, b):
    """greatest common divisor"""
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def solve(f):
    t = f.read_int()
    ans = []

    def solve2():
        a, b, c, d = f.read_int_list()

        g1 = gcd(gcd(a, b), d)

        if d < b: return 'No'
        if a < b: return 'No'
        if b <= c+g1: return 'Yes'
        g2 = gcd(b, d)

        lo = ((c+1)-a)%g2
        if lo == 0 or lo + (b-c-1) >= g2: return 'No'

        return 'Yes'

    for _ in xrange(t):
        ans.append(solve2())

    return "\n".join(ans)


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case 
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

Solution (Python):
import fractions

def main():
	t = int(input())
	qs = [list(map(int, input().split())) for _ in range(t)]
	for q in qs:
		sub(q)

def sub(q):
	a, b, c, d = q
	if d - b < 0:
		print("No")
		return
	
	if a - b < 0:
		print("No")
		return

	if b > c:
		gcd_bd = fractions.gcd(d, b)
		i = - 10
		while True:
			if 0 < gcd_bd * i + (a - c) % gcd_bd < b - c:
				print("No")
				return
			elif gcd_bd * i + (a - c) % gcd_bd >= b - c:
				print("Yes")
				return
			i += 1
				
	print("Yes")
	return
	
if __name__ == '__main__':
	main()

Solution (Python):
import fractions


def solve(a, b, c, d):
    if a < b or d < b:
        return False
    if b <= c + 1:
        return True
    gcd_bd = fractions.gcd(b, d)
    cc = c - a % gcd_bd
    b //= gcd_bd
    cc //= gcd_bd
    if b <= cc + 1:
        return True
    return False


t = int(input())
buf = []
for _ in range(t):
    a, b, c, d = map(int, input().split())
    buf.append('Yes' if solve(a, b, c, d) else 'No')
print('\n'.join(map(str, buf)))

Solution (Python):
def gcd(a, b):
    if a < b:
        a,b = b,a
    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')
    else:
        g = gcd(B,D)
        k = B//g
        r = (A-C)%B
        if r == 0:
            sm = C
        else:
            sm = C+r-B
        if sm < 0:
            print('No')
        else:
            s = sm%g
            if s + (k-1)*g <= C:
                print('Yes')
            else:
                print('No')

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

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

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

Solution (Python):
from fractions import gcd

def solve(A,B,C,D):
  if D<B:
    return "No"
  if A<B:
    return "No"
  if C>=B-1:
    return "Yes"
  g = gcd(B,D)
  if A-(A-C-1)/g*g<B:
    return "No"
  return "Yes"

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

Solution (Python):

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


def calc():
    a, b, c, d = map(int, raw_input().split())
    if a < b:
        return 'No'
    if d < b:
        return 'No'
    if c >= b:
        return 'Yes'
    g = gcd(b, d)
    a %= b
    n = (b - a) / g
    if a + g * n == b:
        n -= 1
    if a + g * n > c:
        return 'No'
    else:
        return 'Yes'


def main():
    t = input()
    for _ in range(t):
        print calc()


if __name__ == '__main__':
    main()

Solution (Python):
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

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:
    print("  V1", file=stderr)
    return False
  CC = C + 1
  if B <= CC:
    print("  V2", file=stderr)
    return True
  g = gcd(D, B)
  
  if CC <= B - g:
    print("  V3", file=stderr)
    return False
  else:
    print("  V4", file=stderr)
    return A % g < CC % g

T = read()
for _ in range(T):
  A, B, C, D = reads()
  print("Yes" if solve(A, B, C, D) else "No")

Solution (Python):
T = int(input())
def gcd(a,b):
	if a < b:
		a,b = b,a
	while b > 0:
		c = a % b
		a = b
		b = c
	return a

YES = 'Yes'
NO = 'No'
for i in range(T):
	A,B,C,D = map(int,input().split())
	if D < B or A < B:
		print(NO)
		continue
	D = D % B
	if C >= B:
		print(YES)
		continue
	rest = A % B
	if rest > C:
		print(NO)
		continue
	if D == 0:
		print(YES)
		continue
	g = gcd(B,D)
	left = C - rest
	right = B - rest
	n = left // g + 1
	if n * g < right:
		print(NO)
	else:
		print(YES)

Solution (Python):
from fractions import gcd

def solve():
    a, b, c, d = map(int, input().split(' '))
    if a < b or d < b: return False
    if c >= b: return True
    
    a = a % b
    d = d % b
    x = gcd(b, d)
    k = (b - a) // x
    if (b - a) % x == 0: k -= 1
    return not (c < a + k * x < b)
    
def main():
    t = int(input())
    ans = []
    for _ in range(t):
        ans.append(['No','Yes'][solve()])
    for a in ans:
        print(a)

if __name__ == '__main__':
    main()

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

T = int(input())
for i in range(T):
    A,B,C,D = map(int,input().split())
    if B > D:
        print('No')
    elif A < B:
        print('No')
    elif C + 1 >= B:
        print('Yes')
    else:
        q = gcd(B,D)
        r = (A-C)%q
        if r == 0:
            r = q
        if C + r >= B:
            print('Yes')
        else:
            print('No')

Solution (Python):
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

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


T = int(input())

for turn in range(1, T+1):
    init, sell, base, add = map(int, input().split())

    hoge = gcd(sell, add)

    ans = "Yes"
    if init < sell or sell > add:
        ans = "No"
    elif base+hoge >= sell:
        if init % sell > base:
            ans = "No"
    else:
        ans = "No"

    print(ans)

Solution (Python):

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
T = int(input())
res_list = []

for _ in range(T):
    A, B, C, D = map(int, input().split())
    E = gcd(B, D)
    res = "Yes"
    if A < B:
        res = "No"
    if D < B:
        res = "No"
    if C < B - E:
        res = "No"
    F = A - ((A - C - 1) // B) * B - B
    if F < 0:
        res = "No"
    res_list.append(res)
for i in range(T):
    print(res_list[i])

Solution (Python):


def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

T = int(input())
for _ in range(T):
    A, B, C, D = map(int, input().split())
    if D < B or A < B:
        print("No")
    else:
        g = egcd(B, D)[0]
        mA = A % g
        mC = C % g
        k = C + (mA - mC if mA - mC > 0 else mA - mC + g)
        k -= B
        if k >= 0:
            print("Yes")
        else:
            print("No")

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

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

Solution (Python):
import fractions as math


def read_ints():
    return [int(c) for c in input().split()]


def solve(a, b, c, d):
    if a < b:
        return False
    if d < b:
        return False
    if c >= b:
        return True
    e = a % b
    delta = d % b
    if delta == 0:
        return e <= c
    g = math.gcd(b, delta)
    maxv = b - g
    return maxv <= c


def main():
    n = int(input())
    for _ in range(n):
        print("Yes" if solve(*read_ints()) else "No")


if __name__ == '__main__':
    main()

Solution (Python):
from fractions import gcd
t = int(raw_input())
for _ in xrange(t):
    a, b, c, d = map(int, raw_input().split())
    if a < b or b > d:
        print 'No'
        continue
    a -= b
    if a > c:
        a -= (a - c + b - 1) / b * b
    if a < 0:
        print 'No'
    elif d % b == 0 or c >= b:
        print 'Yes'
    else:
        d = gcd(b, d)
        a += (c - a + d) / d * d
        print 'No' if a < b else 'Yes'

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

t=int(input())
result=[]
for i in range(t):
    a,b,c,d=list(map(int,input().split()))
    if b>d:
        result.append('No')
    elif a<b:
        result.append('No')
    elif a%b>c:
        result.append('No')
    elif b-c-1<gcd(b,d):
        result.append('Yes')
    else:
        result.append('No')

for r in result:
    print(r)

Solution (Python):
T = int(input())
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n
def check(a, b, c, d):
    if b > a or d < b:
        return 0
    g = gcd(b, d)
    k = (a - c - 1) // g
    p = a - k*g
    if p - b < 0:
        return 0
    return 1

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

Solution (Python):


import sys

input=sys.stdin.readline

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

def good(a,b,c,d):
    
    if b>a: return 0
    if b>d: return 0
    if b<=c: return 1
    
    
    
    a%=b
    d%=b
    g=gcd(b,d)
    a+=((b-a-1)//g)*g
    return not c<a<b

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