CodeEff/ECCO huggingface dataset:
# Original solution
#!/usr/bin/env python3
import sys
from collections import defaultdict

def solve(N: int, S: "List[str]"):

    d = defaultdict(int)
    for s in S:
        d[s]+=1

    return '\n'.join(sorted([kv[0] for kv in list(d.items()) if kv[1] == max(d.values())]))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    print((solve(N, S)))

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys
from collections import defaultdict

def solve(N: int, S: "List[str]"):
    d = defaultdict(int)
    cnt_common = 0
    commons = []

    for s in S:
        d[s] += 1
        if cnt_common < d[s]:
            cnt_common=d[s]
            commons = [s]
        elif cnt_common == d[s]:
            commons.append(s)

    return '\n'.join(sorted(commons))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    print((solve(N, S)))

if __name__ == '__main__':
    main()
# Original solution
import collections

N = int(input())
S = [input() for _ in range(N)]

cnt = collections.Counter(S)

ans_list = []

for key, value in cnt.items():
    if value == max(cnt.values()):
        ans_list.append(key)

print(*sorted(ans_list), sep='\n')



# Optimized solution
import collections

N = int(input())
S = [input() for _ in range(N)]

cnt = collections.Counter(S)
max_cnt = max(cnt.values())

ans_list = []

for key, value in cnt.items():
    if value == max_cnt:
        ans_list.append(key)

print(*sorted(ans_list), sep='\n')
# Original solution
import collections
import sys
input = sys.stdin.readline
n = int(input())
s = []
for i in range(n):
  s.append(input())
#print(s)
c = collections.Counter(s)
#print(c.most_common())
m = c.most_common()[0][1]
l = len(c.most_common())
ans = []
for i in range(l):
  if c.most_common()[i][1] == m:
    ans.append(c.most_common()[i][0])
  else:
    break
ans0 = sorted(ans)
for i in range(len(ans0)):
  print(ans0[i],end="")


# Optimized solution
import collections
import sys
input = sys.stdin.readline
n = int(input())
s = []
for i in range(n):
  s.append(input())
#print(s)
c = collections.Counter(s)
#print(c.most_common())
x = c.most_common()
m = x[0][1]
l = len(x)
ans = []
for i in range(l):
  if x[i][1] == m:
    ans.append(x[i][0])
  else:
    break
ans0 = sorted(ans)
for i in range(len(ans0)):
  print(ans0[i],end="")
# Original solution
from collections import Counter
import heapq

n = int(eval(input()))
ss = []
for _ in range(n):
    ss.append(input().rstrip())
ctr = Counter(ss)
heap = [(-v, k) for k, v in list(ctr.items())]
heapq.heapify(heap)
maxv = heap[0][0]
while heap:
    c = heapq.heappop(heap)
    if c[0] != maxv:
        break
    print((c[1]))


# Optimized solution
from collections import Counter

n = int(eval(input()))
ss = []
for _ in range(n):
    ss.append(input().rstrip())
ctr = Counter(ss)

a = sorted([(-v, k) for k, v in list(ctr.items())])
maxv = a[0][0]
for i in range(len(a)):
    if a[i][0] != maxv:
        break
    print((a[i][1]))
# Original solution
from collections import Counter
n=int(input())
S=[input() for _ in range(n)]

cnt=Counter(S)
maxcnt=cnt.most_common()[0][1]
ans=[]
for i in range(len(cnt)):
  if cnt.most_common()[i][1]==maxcnt:
    ans.append(cnt.most_common()[i][0])
  else:
    break
ans.sort()
print(*ans,sep='\n')


# Optimized solution
from collections import Counter
n=int(input())
S=[input() for _ in range(n)]

cnt=Counter(S)
cnt=cnt.most_common()
maxcnt=cnt[0][1]
ans=[]
for i in range(len(cnt)):
  if cnt[i][1]==maxcnt:
    ans.append(cnt[i][0])
  else:
    break
ans.sort()
print(*ans,sep='\n')
# Original solution
N = int(eval(input()))
C = {}
for _ in range(N):
    s = input().strip()
    if s not in C:
        C[s] = 0
    C[s] += 1
C = sorted(list(C.items()),key=lambda x:x[0])
C = sorted(C,key=lambda x:x[1],reverse=True)
k = C[0][1]
for i in range(len(C)):
    if C[i][1]==k:
        print((C[i][0]))
    else:break

# Optimized solution
N = int(eval(input()))
C = {}
for _ in range(N):
    s = input().strip()
    if s not in C:
        C[s]=0
    C[s] += 1
cmax = 0
for s in C:
    cmax = max(cmax,C[s])
A = []
for s in C:
    if C[s]==cmax:
        A.append(s)
A = sorted(A)
for i in range(len(A)):
    print((A[i]))
# Original solution
n = int(input())
a = {}
for i in range(n):
  s = input()
  a[s] = a.get(s,0) + 1
b = sorted([i for i in a.keys() if a[i]==max(a.values())])
[print(i) for i in b]


# Optimized solution
n = int(input())
a = {}
for i in range(n):
  s = input()
  a[s] = a.get(s,0) + 1
max_a = max(a.values())
b = sorted([i for i in a.keys() if a[i]==max_a])
[print(i) for i in b]
# Original solution
import collections
import itertools

n = int(input())
l = [input() for _ in [0] * n]

counter = collections.Counter(l)

a = counter.most_common()[0][-1]
b = itertools.takewhile(
    lambda kv: kv[-1] == a, counter.most_common()
)

c = sorted(list(k for k, v in b))
print(*c,sep='\n')




# Optimized solution
import collections

n = int(input())
l = [input() for _ in [0] * n]

counted = collections.Counter(l)
#print(counted)
# 最頻値を求める
m = max(counted.values())
#print(m)
# 頻出数の文字を集める
chars = [key for key, value in counted.items()
             if value == m]

print(*sorted(chars),sep='\n')
# Original solution
from collections import Counter
n=int(input().rstrip())
d=dict()
for _ in range(n):
    s=input().rstrip()
    if s not in d:
      d[s]=1
    else:
      d[s]+=1
ans=Counter(d).most_common()
ans.sort(key=lambda x: (-x[1],x[0]))
m=ans[0][1]
for i in ans:
    if i[1]!=m:
        break
    print((i[0]))

# Optimized solution
#import pysnooper
#import numpy
#import os,re,sys,operator
from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6)
input=stdin.readline

def main():
    n=int(input().rstrip())
    d=dict()
    for _ in range(n):
        s=input().rstrip()
        if s not in d: d[s]=1
        else: d[s]+=1
    ans=Counter(d).most_common()
    ans.sort(key=lambda x: (-x[1],x[0]))
    ma=ans[0][1]
    for i in ans:
        if i[1]!=ma: break
        print((i[0]))

if __name__=="__main__":
    main()
# Original solution
from collections import Counter
import sys
input = sys.stdin.readline
n=int(eval(input()))
s=[]
for _ in range(n):
    s.append(input().rstrip())
c = Counter(s)
ans=[]
max_vote = max(c.values())
for i,j in list(c.items()):
    if j == max_vote:
        ans.append(i)
print(("\n".join(sorted(ans))))

# Optimized solution
def main():
    from collections import Counter
    import sys
    input = sys.stdin.readline
    n=int(eval(input()))
    s=[]
    for _ in range(n):
        s.append(input().rstrip())
    c = Counter(s)
    ans=[]
    max_vote = max(c.values())
    for i,j in list(c.items()):
        if j == max_vote:
            ans.append(i)
    print(("\n".join(sorted(ans))))
main()
# Original solution
def main():
    from collections import Counter
    import sys
    input = sys.stdin.readline
    n=int(eval(input()))
    s=[]
    for _ in [0]*n:
        s.append(input().rstrip())
    c = Counter(s)
    ans=[]
    max_vote = max(c.values())
    for i,j in list(c.items()):
        if j == max_vote:
            ans.append(i)
    print(("\n".join(sorted(ans))))
main()

# Optimized solution
def main():
    from collections import Counter
    import sys
    input = sys.stdin.readline
    n=int(eval(input()))
    s=[]
    ap = s.append
    for _ in [0]*n:
        ap(input().rstrip())
    c = Counter(s)
    ans=[]
    max_vote = max(c.values())
    for i,j in list(c.items()):
        if j == max_vote:
            ans.append(i)
    print(("\n".join(sorted(ans))))
main()
# Original solution
import collections
N = int(input())
S = [input() for _ in range(N)]

if len(S) == len(set(S)):
  [print(a) for a in sorted(S)]
else:
  c = collections.Counter(S)
  ans = sorted([i[0] for i in c.items() if i[1] == c.most_common()[0][1]])
  [print(a) for a in ans]


# Optimized solution
import collections
N = int(input())
S = [input() for _ in range(N)]

if len(S) == len(set(S)):
  ans = S
else:
  ans = []
  c = collections.Counter(S)
  c_common = c.most_common()
  max_vote = c_common[0][1]
  for k in range(len(set(S))):
    if c_common[k][1]== max_vote:
      ans.append(c_common[k][0])
    else:
      break
[print(a) for a in sorted(ans)]
# Original solution
from collections import Counter

N = int(input())
c = Counter()
for i in range(N):
    k = input()
    v = c.setdefault(k, 0)
    c[k] = v + 1
ans = sorted([k for k,n in c.items() if n == max(c.values())])
[print(k) for k in ans]


# Optimized solution
from collections import Counter

N = int(input())
c = Counter()
l = 0
for i in range(N):
    k = input()
    v = c.setdefault(k, 0)
    c[k] = v + 1
    if l < c[k]:
        l = c[k]
ans = sorted([k for k, n in c.items() if n==l])
[print(k) for k in ans]
# Original solution
from collections import Counter
import sys
n = int(sys.stdin.readline())
sn = sys.stdin.read().split()
c = Counter(sn)
c = sorted(list(c.items()), key=lambda x: (-x[1], x[0]))
num = c[0][1]
for i, j in c:
  if j == num:
    print(i)
  else:
    quit()

# Optimized solution
from collections import Counter
import sys
n = int(sys.stdin.readline())
sn = sys.stdin.read().split()
c = Counter(sn)
num = max(c.values())
ans = [i for i, j in list(c.items()) if j == num]
ans.sort()
print(('\n'.join(ans)))
# Original solution
import collections, sys

n = sys.stdin.readline()
s = []
for _ in range(0,int(n)):
  s.append(sys.stdin.readline().replace('\n',''))

if len(set(s)) == 1:
  print((s[0]))
  sys.exit()  

c = collections.Counter(s)
max = c.most_common()[0][1]

l = []
l.append(c.most_common()[0][0])
for i in range(0,len(s)):
  if c.most_common()[i][1] == max:
    l.append(c.most_common()[i][0])
  else:
    break
ll = sorted(set(l))
for ls in ll:
  print(ls)

# Optimized solution
import collections, sys

n = sys.stdin.readline()
s = []
for _ in range(0,int(n)):
  s.append(sys.stdin.readline().replace('\n',''))

c = collections.Counter(s)
max = c.most_common()[0][1]
l = sorted(list(dict([x for x in list(c.items()) if x[1]==max]).keys()))
for k in l:
  print(k)
# Original solution
def resolve():
    import sys
    from collections import Counter
    n = int(eval(input()))
    s = [sys.stdin.readline().rstrip() for i in range(n)]
    d = Counter(s).most_common()
    e = d[0][1]
    f = ([i for i in set(s) if s.count(i) == e])
    f = sorted(f)
    for i in f:
        print(i)
resolve()

# Optimized solution
def resolve():
    import sys
    from collections import Counter
    n = int(eval(input()))
    s = [sys.stdin.readline().rstrip() for i in range(n)]
    d = Counter(s).most_common()
    e = d[0][1]
    ans = []
    for i in range(len(d)):
        if d[i][1] != e:
            break
        else:
            ans.append(d[i][0])
    for j in sorted(ans):
        print(j)
resolve()
# Original solution
import collections
n = int(input())
words = []
for i in range(n):
  words.append(input())
c = collections.Counter(words)
max_w = []
for i in c.most_common():
  if i[1]==c.most_common()[0][1]:
    max_w.append(i[0])
max_w.sort()
[print(j) for j in max_w]


# Optimized solution
import collections
n = int(input())
words = []
[words.append(input()) for i in range(n)]
c = collections.Counter(words)
cc = c.most_common()
max_w = []
for i in cc:
  if i[1]==cc[0][1]:
    max_w.append(i[0])
max_w.sort()
[print(j) for j in max_w]
# Original solution
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    S = [""] * N
    for i in range(N):
        S[i] = input().rstrip()

    c = Counter(S)
    max_v = max(c.values())
    ans = [k for k, v in c.items() if v == max_v]
    ans.sort()

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


if __name__ == "__main__":
    main()


# Optimized solution
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    S = [""] * N
    for i in range(N):
        S[i] = input().rstrip()

    c = Counter(S)
    max_v = max(c.values())
    ans = [k for k, v in list(c.items()) if v == max_v]
    ans.sort()

    print(("\n".join(ans)))


if __name__ == "__main__":
    main()
# Original solution
from collections import defaultdict
n = int(input())
S = [input() for _ in range(n)]
d = defaultdict(int)
for s in S:
    d[s] += 1
m = max(d.values())
items = d.items()
a = sorted([c[0] for c in items if c[1] == m])
[print(i) for i in a]


# Optimized solution
from collections import Counter
def main():
    n = int(input())
    S = [input() for _ in range(n)]
    c = Counter(S).most_common()
    V = c[0][1]
    ans = [k for k, v in c if v == V]
    [print(a) for a in sorted(ans)]

if __name__ == '__main__':
    main()
# Original solution
import sys
input = sys.stdin.readline
N = int(eval(input()))
S = []
for x in range(N):
    S.append(input().rstrip())
S_label_n = []
S_label = list(set(S))
for x in S_label:
    S_label_n.append(S.count(x))
max_n =max(S_label_n)
maxIndex = [i for i, x in enumerate(S_label_n) if x ==max_n ]
ans_list = []
for x in maxIndex:
    ans_list.append(S_label[x])
ans_list.sort()
for x in ans_list:
    print(x)

# Optimized solution
import sys
input = sys.stdin.readline
N = int(eval(input()))
dictS = {}
for x in range(N):
    tmp = input().rstrip()
    if tmp in dictS:
        dictS[tmp] = dictS[tmp]+1
    else:
        dictS[tmp]=1
        
max_n =max(dictS.values())
maxIndex = [x for x in list(dictS.items()) if x[1] ==max_n ]
ans_list = []
for x in maxIndex:
    ans_list.append(x[0])
ans_list.sort()
for x in ans_list:
    print(x)
# Original solution

from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
a = c.most_common()[0][1]
ans = []
for i in range(len(c)):
  if c.most_common()[i][1] == a:
    ans.append(c.most_common()[i][0])

ans.sort()
print(*ans,sep="\n")


# Optimized solution

from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
C = c.most_common()
a = C[0][1]
ans = []
for i in range(len(c)):
  if C[i][1] == a:
    ans.append(C[i][0])

ans.sort()
print(*ans,sep="\n")
# Original solution
from collections import Counter

n = int(input())
S = [input() for i in range(n)]

L = Counter(S)
m = 0
for v in L.values():
    m = max(m, v)
ans = []
for k, v in L.items():
    if v == m:
        ans.append(k)
ans.sort()
print(*ans, sep="\n")


# Optimized solution
from collections import Counter

N = int(input())
S = [input() for i in range(N)]

C = Counter(S)
max_cnt = max(C.values())

names = [names for names, values in C.items() if values == max_cnt]
names.sort()

print(*names, sep="\n")
# Original solution
from collections import Counter


N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得

counted = Counter(s)
#最頻値が同値である場合全て出力したい
#頻出数ではなく、文字だけ出力したい
#print(s.most_common()[0])

ret = [letter for letter,count in counted.most_common() if count == counted.most_common()[0][1]]
new_ret=sorted(ret)
[print(i) for i in new_ret]


# Optimized solution
from collections import Counter


N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得
ans=[]

counted = Counter(s)#
counted_sort=counted.most_common()

for i in range(len(counted_sort)):
    if counted_sort[i][1]==counted_sort[0][1]:
        ans.append(counted_sort[i][0])


[print(i) for i in sorted(ans)]
# Original solution
n, k = list(map(int, input().split()))
a = [eval(input()) for i in range(n+k)]
cnt = {i:0 for i in range(n)}
for i in range(n,n+k):
    for j in range(n):
        if a[i] >= a[j]:
            cnt[j] += 1
            break
print(sorted(list(cnt.items()), key = lambda x:x[1], reverse = True)[0][0] + 1)

# Optimized solution
n, k = list(map(int, input().split()))
a = [eval(input()) for i in range(n+k)]
c = [0]*n
for i in range(n,n+k):
    for j in range(n):
        if a[i] >= a[j]:
            c[j] += 1
            break
print(c.index(max(c)) + 1)
# Original solution
T=int(eval(input()))
 
Query=[]
for i in range(T):
  Query.append(list(map(int,input().split())))
 
for i in range(T):
  appear=[]
  appear.append(Query[i][0])
  while(True):
    if Query[i][0]%Query[i][1]>Query[i][2] or Query[i][0]<Query[i][1]:
      print('No')
      break;
    Query[i][0]=Query[i][0]%Query[i][1] #昼
    if Query[i][0] in appear:
      print('Yes')
      break;
    else:
      appear.append(Query[i][0])
    if Query[i][0]<=Query[i][2]: #夜
      Query[i][0]+=Query[i][3]

# Optimized solution
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
T=int(eval(input()))
 
Query=[]
for i in range(T):
  Query.append(list(map(int,input().split())))
 
for i in range(T):
  while(True):
    if Query[i][0]%Query[i][1]>Query[i][2] or Query[i][0]<Query[i][1] or Query[i][1]>Query[i][3]:
      print('No')
      break;
    G=gcd(Query[i][1],Query[i][3]) #この倍数分の増減のみ考えれば良い
    '''
    A,B,C,DがQuery[i]の0,1,2,3に対応
    BmodG,DmodGは0(GはB,Dの約数であるため)よりmodGの世界で個数の増減はない。昼の購入で0個減少。夜の仕入れで0個増加。
    つまり、初期個数をAmodGとすると、個数は一定
    出現する可能性のあるBは買う個数であり、B-Gを考えると、買いきれない個数で出現しうる最大の個数が求まる。
    但し、初期個数を考える必要がある。
    初期個数によってループする幅が一緒でも取りうる値は異なる。
    
    例：
    B=24,C=19,D=36 この時,G=12
    
    A=31の場合 AmodG(本来の個数)
    7(31)→7(7)→7(43)→7(19)→7(31)→...
    A=30の場合 AmodG(本来の個数)
    6(30)→6(6)→6(42)→6(18)→6(30)→...
    
    Bを超えない最大数について、初期個数を考慮すると、B-G+AmodGとなる。
    G>AmodGであるため、この数が購入数Bを超えることはない
    つまり、B-G+AmodG>CならばNo,そうでなければYes
    '''
    if Query[i][1]-G+Query[i][0]%G>Query[i][2]:
      print('No')
      break;
    else:
      print('Yes')
      break;
# Original solution
t = int(eval(input()))
a = []
for i in range(t):
  a.append(list(map(int,input().split())))
for j in a:
  b = j[0]
  for k in range(j[1]):
    if j[0] < j[1]:
      print("No")
      break
    j[0] %= j[1]
    if j[0] <= j[2]:
      j[0] += j[3]
    else:
      print("No")
      break
    if j[0] < j[1]:
      print("No")
      break
    if k == j[1]-1:
      print("Yes")
    

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

t = int(eval(input()))
a = []
d = 0
for i in range(t):
  a.append(list(map(int,input().split())))
for j in a:
  if j[0] < j[1] or j[1] > j[3]:
    print("No")
  else:
    b = j[0] % j[1]
    k = gcd(j[1],j[3])
    c = j[0] % k
    d = j[2] % k
    if c > d:
      e = j[2] + c - d
    else:
      e = j[2] + k + c - d

    if j[1] > e:
      print("No")
    else:
      print("Yes")
# Original solution
def main():
  t = int(eval(input()))
  for _ in range(t):
    a, b, c, d = list(map(int, input().split()))
    if (a < b or d < b):
      print("No")
      continue
    if (c >= b - 1):
      print("Yes")
      continue
  
    a %= b
    if a > c:
      print("No")
      continue
    d %= b
    if d == 0:
      print("Yes")
      continue
    if b % d != 0:
      print("No")
      continue
    for i in range(b // d):
      a = (a + d) % b
      if a > c:
        print("No")
        break
    else:
      print("Yes")
main()

# Optimized solution
def gcd(a, b):
    if b == 0:return a
    return gcd(b, a % b)

t = int(eval(input()))
for _ in range(t):
    a, b, c, d = list(map(int, input().split()))
    #exception
    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"))
# Original solution
t = int(eval(input()))
for i in range(t):
    a, b, c, d = list(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
        else:
            break
        if a in rec:
            flag = True
            break
        num += 1
        rec.append(a)
    if flag:
        print("Yes")
    else:
        print("No")

# Optimized solution
T = int(eval(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 = list(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')
# Original solution
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from math import ceil

def solve(A, B, C, D):
    zaiko = A
    visited = set([zaiko])
    while zaiko >= B:
        zaiko -= B
        if zaiko > C:
            zaiko -= ceil((zaiko - C) / B) * B
            if zaiko < 0 or zaiko > C: return False
        zaiko += D
        if zaiko in visited: return True
        visited.add(zaiko)
    return False


T = int(eval(input()))
for i in range(T):
    A, B, C, D = [int(t) for t in input().split()]
    print(('Yes' if solve(A, B, C, D) else 'No'))

# Optimized solution
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from math import ceil

def gcd(a, b):
    assert a > 0 and b > 0
    while b > 0:
        r = a % b
        a = b
        b = r
    return a

def solve(A, B, C, D):
    if A < B or D < B: return False
    if A % B > C: return False
    if D % B == 0: return True

    g = gcd(B, D)
    r = A % g  # +D -B を繰り返すと x % g == r であるxを訪れる
    # x % g == r and C < x < B である x が存在するなら False を返す
    return not (C < B - g + r)

T = int(eval(input()))
for i in range(T):
    A, B, C, D = [int(t) for t in input().split()]
    print(('Yes' if solve(A, B, C, D) else 'No'))
# Original solution
class query:
    def __init__(self, a, b, c, d):
        self.a = a
        self.b = b
        self.c = c
        self.d = d
    def isEternal(self):
        if self.a < self.b:
            return "No"
        if self.a % self.b > self.c:
            return "No"
        if self.d < self.b:
            return "No"
        d = self.b - self.c
        if d <= 0:
            return "Yes"
        if self.b % d == 0 and self.d % d == 0:
            return "Yes"
        s = self.a % self.b
        db = self.d % self.b
        if db == 0:
            return "Yes"
        for i in range(self.b - 1):
            s += db
            if s >= self.b:
                return "Yes"
            if s > self.c:
                return "No"
        return "Yes"

if __name__ == "__main__":
    t = int(eval(input()))
    querys = [query(*[int(s) for s in input().split()]) for _ in range(t)]
    for q in querys:
        print((q.isEternal()))


# Optimized solution
def gcd(a, b):
    r = a % b
    while r != 0:
        a, b, r = b, r, b % r
    return b

class query:
    def __init__(self, a, b, c, d):
        self.a = a
        self.b = b
        self.c = c
        self.d = d
    def isEternal(self):
        if self.a < self.b:
            return "No"
        if self.d < self.b:
            return "No"
        if self.b <= self.c:
            return "Yes"
        g = gcd(self.d, self.b)
        if self.b - g + self.a % g > self.c:
            return "No"
        return "Yes"

if __name__ == "__main__":
    t = int(eval(input()))
    querys = [query(*[int(s) for s in input().split()]) for _ in range(t)]
    for q in querys:
        print((q.isEternal()))