Harryxun/stf_run huggingface dataset:
#import math
from fractions import gcd

N = int(input())
As = [int(elm) for elm in input().split(" ")] 

if N >= 3:
    L = []
    R = []

    gl = As[0]
    gr = As[N-1]
    L.append(gl)
    R.append(gr)

    for i in range(1, N-1):
        gl = gcd(gl, As[i]) 
        L.append(gl)

    for i in range(1, N-1):
        gr = gcd(gr, As[N-i-1])
        R.append(gr)

    for i in range(N):
        if i == 0:
            max_g = R[N-2]
        else:
            if i == N-1:
                cur_g = L[N-2]
            else:
                cur_g = math.gcd(L[i-1], R[N-2-i])
            max_g = max(max_g, cur_g)

    out = max_g
else:
    out = max(As)

print(out)

### FIXED CODE ###

#import math
from fractions import gcd

N = int(input())
As = [int(elm) for elm in input().split(" ")] 


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

if N >= 3:
    gs = []
    for i in range(0, (N//2)*2 , 2):
        g = gcd(As[i], As[i+1])
        gs.append(g)
    if N % 2 == 1:
        gs.append(As[N-1])

    while len(gs) != 2:
        #print(gs)
        new_gs = []
        N1 = len(gs)
        #print("len",len(gs), (N1//2)*2)
        for i in range(0, (N1//2)*2, 2):
            g = gcd(gs[i], gs[i+1])
            new_gs.append(g)
        if N1 % 2 == 1:
            new_gs.append(gs[-1])
        gs = new_gs

    g1, g2 = gs
    d1 = divisor(g1) 
    d2 = divisor(g2) 
    ds = sorted(d1 + d2, reverse=True)

    #print(gs)
    #print(ds)
    for d in ds:
        count = sum([int(A % d == 0) for A in As])
        if count >= N-1:
            out = d
            break

else:
    out = max(As)

print(out)
def get_root(s):
    if s != root[s]:
        root[s] = get_root(root[s])
        return root[s]
    return s

def unite(s, t):
    root_s = get_root(s)
    root_t = get_root(t)
    if not root_s == root_t:
        if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
        elif rank[s] > rank[t]:
            root[root_t] = root_s
        else:
            root[root_s] = root_t

def same(s, t):
    if get_root(s) == get_root(t):
        return True
    else:
        return False

def get_size(s):
    return size[get_root(s)]

def update_size(x, y, s):
    size[get_root(s)] = x + y

n, m = map(int, input().split())
c = (n * (n - 1)) // 2
root = [i for i in range(n)]
rank = [1 for _ in range(n)]
size = [1 for _ in range(n)]
ans = [c]
v = [list(map(int, input().split())) for _ in range(m)]
for i in range(m - 1, -1, -1):
    u = v[i]
    u[0] -= 1
    u[1] -= 1
    if not same(u[0], u[1]):
        x = get_size(u[0])
        y = get_size(u[1])
        unite(u[0], u[1])
        update_size(x, y, u[0])
        c -= x * y
    ans.append(c)
for i in range(m - 1, -1, -1):
    print(ans[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

def get_root(s):
    if s != root[s]:
        root[s] = get_root(root[s])
        return root[s]
    return s

def unite(s, t):
    root_s = get_root(s)
    root_t = get_root(t)
    if not root_s == root_t:
        if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
        elif rank[s] > rank[t]:
            root[root_t] = root_s
        else:
            root[root_s] = root_t

def same(s, t):
    if get_root(s) == get_root(t):
        return True
    else:
        return False

def get_size(s):
    return size[get_root(s)]

def update_size(x, y, s):
    size[get_root(s)] = x + y

n, m = map(int, input().split())
c = (n * (n - 1)) // 2
root = [i for i in range(n)]
rank = [1 for _ in range(n)]
size = [1 for _ in range(n)]
ans = [c]
v = [list(map(int, input().split())) for _ in range(m)]
for i in range(m - 1, -1, -1):
    u = v[i]
    u[0] -= 1
    u[1] -= 1
    if not same(u[0], u[1]):
        x = get_size(u[0])
        y = get_size(u[1])
        unite(u[0], u[1])
        update_size(x, y, u[0])
        c -= x * y
    ans.append(c)
for i in range(m - 1, -1, -1):
    print(ans[i])
if K=1:
 print('ACL')
elif K=2:
 print('ACL'*2)
elif K=3:
 print('ACL'*3)
elif K=4:
 print('ACL'*4)
else:
 print('ACL'*5)

### FIXED CODE ###

print('ACL'*int(input()))
from collections import defaultdict,deque
import sys
input=sys.stdin.readline
N,M=map(int,input().split())
if M==0:
  print(-1)
  exit()
G=defaultdict(set)
for i in range(M):
  a,b,c=map(int,input().split())
  G[a+(c<<30)].add(b+(c<<30))
  G[b+(c<<30)].add(a+(c<<30))
  G[a].add(a+(c<<30))
  G[b].add(b+(c<<30))
  G[a+(c<<30)].add(a)
  G[b+(c<<30)].add(b)
def BFS(x):
  d={}
  for k in G.keys():
    d[k]=float("inf")
  stack=deque([(x,0)])
  while stack:
    s,m=stack.popleft()
    if s==N:
      return m
    if d[s]>m:
      d[s]=m
      if s>=(1<<30):
        for i in G[s]:
          if d[i]>10**30:
            stack.appendleft((i,m))
      else: 
        for i in G[s]:
          if d[i]>10**30:
            stack.append((i,m+1))
  return -1

print(BFS(1))



      
    

### FIXED CODE ###

from collections import defaultdict,deque
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
N,M=map(int,input().split())
if M==0:
  print(-1)
  exit()
G=defaultdict(set)
for i in range(M):
  a,b,c=map(int,input().split())
  G[a+(c<<30)].add(b+(c<<30))
  G[b+(c<<30)].add(a+(c<<30))
  G[a].add(a+(c<<30))
  G[b].add(b+(c<<30))
  G[a+(c<<30)].add(a)
  G[b+(c<<30)].add(b)
def BFS(x):
  d={}
  for k in G.keys():
    d[k]=float("inf")
  stack=deque([(x,0)])
  if x not in d:
    return -1
  while stack:
    s,m=stack.popleft()
    if s==N:
      return m
    if d[s]>m:
      d[s]=m
      if s>=(1<<30):
        for i in G[s]:
          if d[i]>10**30:
            stack.appendleft((i,m))
      else: 
        for i in G[s]:
          if d[i]>10**30:
            stack.append((i,m+1))
  return -1

print(BFS(1))
def solver2(a, b, c, k):
    d = deque()
    n = len(a)
    for p in range(n):
        for q in range(n):
            for r in range(n):
                if (p + 1) * (q + 1) * (r + 1) > k:
                    continue
                d.append(a[-p - 1] + b[-q - 1] + c[-r - 1])
    it = reversed(sorted(d))
    for _ in range(k):
        print(next(it))


if __name__ == "__main__":
    x, y, z, k = list(map(int, input().split(" ")))
    a = sorted(list(map(int, input().split(" "))))
    b = sorted(list(map(int, input().split(" "))))
    c = sorted(list(map(int, input().split(" "))))
    solver2(a, b, c, k)


### FIXED CODE ###

from itertools import product, chain

x, y, z, k = list(map(int, input().split(" ")))
a = sorted(list(map(int, input().split(" "))))
b = sorted(list(map(int, input().split(" "))))
c = sorted(list(map(int, input().split(" "))))

apb_sorted = sorted([a + b for a, b in product(a, b)])[-k:]
ans_list = sorted(
    list(chain.from_iterable([[_c + ab for ab in apb_sorted] for _c in c[:k]]))
)
it = reversed(ans_list)
for _ in range(k):
    print(next(it))
N = int(input())
ans = "1" if N = 1 else "0.6" if N%2 = 1 else "0.5"
print(ans)

### FIXED CODE ###

N = int(input())
ans = 0
if N == 1:
    ans = 1
elif N%2 != 1:
    ans= 0.5
else:
    ans=(N+1)/(2*N)
print(ans)
n = int(input())
a = list(map(int, input().split()))
l = []
for i in range(n):
    l.append(0)
for j in a:
    l[j-1] += 1
for k in l:
    print(s)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
sub = []
for i in range(0, n):
    sub.append(0)
for j in a :
    sub[j - 1] += 1
for i in sub:
    print(i)
from  functools import reduce
from  math import gcd
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=[i//2 for i in a]
#print(a)
lc=reduce(lambda x,y: (x*y)//gcd(x,y) , a)
#print(lc)
flag=True
for i in a:
  if (lc/i)%2==0:
    flag=False
    break
if flag==False:
  print(0)
else:
  x=m//lc
  print(x//2) if x%2==0 else print(x//2+1)


### FIXED CODE ###

from  functools import reduce
def gcd(v1,v2):
  v=v1%v2
  if v==0:
    return v2
  else :
    return gcd(v2,v)
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=[i//2 for i in a]
#print(a)
lc=reduce(lambda x,y: (x*y)//gcd(x,y) , a)
#print(lc)
flag=True
for i in a:
  if (lc//i)%2==0:
    flag=False
    break
if flag==False:
  print(0)
else:
  x=m//lc
  print(x//2) if (x%2)==0 else print((x//2)+1)
A, B = map(int, input().split(' '))

def re_define(input_):
    '''強さ順にする'''
    if input_ == 1:
        return 13
    
    return input_ - 1

A = re_define(A)
B = re_define(B)

if A > B:
    print('Alice')
elif A < B:
    print('Bob')
else:
    print('Draw')
p

### FIXED CODE ###

A, B = map(int, input().split(' '))

def re_define(input_):
    '''強さ順にする'''
    if input_ == 1:
        return 13
    
    return input_ - 1

A = re_define(A)
B = re_define(B)

if A > B:
    print('Alice')
elif A < B:
    print('Bob')
else:
    print('Draw')
n = int(input())
a = [int(input()) for i in range(n)]
sa = a.sort()
am, asl = sa[-1], sa[-2]
for i in range(n):
    print(asl if a[i] == am else am)

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
b = a.copy()
b.sort()
a_max = b[-1]
a_second = b[-2]
for i in range(n):
    if a[i] == a_max:
        print(a_second)
    else:
        print(a_max)
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        if i != 0 or i != H-1:
            print("#"+"." * (W-2)+"#")
        else print("#" * W)
    print()


### FIXED CODE ###

while True:
    H,W = map(int,input().split())
    if H==W==0:
        break;
    print("#"*W)
    for i in range(0,H-2):
        print("#"+"."*(W-2)+"#")
    print("#"*W)
    print()
N = int(input())
A = int(input())
B = int(input())
print (min(N*A,B))

### FIXED CODE ###

list1 = [int(i) for i in input().split()]
print (min(list1[0]*list1[1],list1[2]))
N = int(input())
if N<1000:
  print('ABC' + N.zfill(3))
  exit()
print('ABD' + (N-999).zfill(3))

  

### FIXED CODE ###

N = int(input())
if N<1000:
  print('ABC')
  exit()
print('ABD')
n = int(input())
a = list(map(int,input().split()))

d = 0
c = []
for b in range(0,max(a)+1):
    for i in range(0,len(a)):
        d += abs(a[i]-(b+i+1))
    c.append(d)
    d = 0
print(min(c))

### FIXED CODE ###

n = int(input())
if n % 2 != 0:
    print(n*2)
else:
    print(n)
x,y = input().split()
if x < y:
	print('<')
elif x == y:
	print('=')
else
	print('>')


### FIXED CODE ###

x,y = input().split()
if x < y:
	print('<')
elif x == y:
	print('=')
else:
	print('>')
A, B, K = map(int, input().split())
s = set()
for i, n in enumerate(range(A, B+1)):
    if i+1 <= K:
        s.add(n)
for i, n in enumerate(reversed(range(A, B+1))):
    if i+1 <= K:
        s.add(n)
for i in sorted(s):
    print(i)

### FIXED CODE ###

S = input()
if 'a' in S and 'b' in S and 'c' in S:
    print('Yes')
else:
    print('No')
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

score = 0
for i in range(0,N-1):
    if A[i+1] - A[i] == 1:
        score += C[A[i] - 1]

print(score + sum(B))

### FIXED CODE ###

N = int(input())
print(N**3)
n=int(input())
while n-a<1000:
  print(n-a)
  a+=1000

### FIXED CODE ###

n=int(input())
print((1000-n%1000)%1000)
N = int(input())
*S = map(int, open(0).read().split())
SS = {}
for i in range(N):
    if S[i] in SS:
        SS[S[i]] +=1
    else:
        SS[S[i]] = 1
SS = ser = ser.sort_values(ascending=False)
for i in range(N+1):
    print(SS[i])
    if SS[i] != SS[i + 1]:
        break


### FIXED CODE ###

N=int(input())
S = {}
for i in range(N):
    let = input()
    try:
        S[let] += 1
    except:
        S[let] = 1
max_val = max(S.values())
answers = []
for k,v in S.items():
    if v == max_val:
        answers.append(k)
answers.sort()
for ans in answers:
    print(ans)
l, r = map(int, input().split())
if r - l > 3000:
  print(0)
else:
  ans = 3000
  for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
      ans = min(ans, i * j % 2019)
print(ans)
  

### FIXED CODE ###

l, r = map(int, input().split())
mod = 2019
if r - l > 3000:
  print(0)
else:
  ans = mod
  for i in range(l, r + 1):
    for j in range(r, l, -1):
      #print(str(i) + ' ' + str(j))
      if j <= i: break
      ans = min(ans, (i * j) % mod)
  print(ans)
N, K = map(int, input().split())
S = list(input())

p = 0
while K > 0 and p < len(S):
	now = S[p]
	p += 1
	if p >= len(S):
		break
	while now == S[p]:
		p += 1
		if p >= len(S):
			break

	q = p + 1
	if q >= len(S):
		"""
		if S[p] == "R":
			S[p] = "L"
		else:
			S[p] = "R"
		"""
		break
	while S[p] == S[q]:
		q += 1
		if q >= len(S):
			break
	while p < q:
		if S[p] == "R":
			S[p] = "L"
		else:
			S[p] = "R"
		p += 1
		if p >= len(S):
			break
	K -= 1

ret = 0;
print(len(S))
for x in range(len(S)-1):
	print(x)
	if S[x] == S[x + 1]:
		ret += 1
print(ret)


### FIXED CODE ###

N = int(input())
print(N*N*N)
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

l = list(set(s))
a = max (n.count(l[i]) - m.count(l[i]) for i in range(len(l)))

print(a if a > 0 else 0)

### FIXED CODE ###


n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

l = list(set(s))
a = max (s.count(l[i]) - t.count(l[i]) for i in range(len(l)))

print(a if a > 0 else 0)
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n, k = map(int, input().split())
a = list( map(int, input().split()))

ans = 0


a.sort()

print(a)

for j in range(n):
    i = j +1
    if j <= n-k:
        minX = a[i-1]
        ans -= a[i-1]*cmb(n-i,k-1,mod)%mod
    if k -1 <= i:
        maxX = a[i-1]
        ans += a[i-1]*cmb(i-1,k-1,mod)%mod

print(ans%mod)




### FIXED CODE ###

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n, k = map(int, input().split())
a = list( map(int, input().split()))

ans = 0


a.sort()

for j in range(n):
    i = j +1
    if j <= n-k:
        minX = a[i-1]
        ans -= a[i-1]*cmb(n-i,k-1,mod)%mod
    if k -1 <= i:
        maxX = a[i-1]
        ans += a[i-1]*cmb(i-1,k-1,mod)%mod

print(ans%mod)
import math
r = int(input())
print(r**2*math.pi,2*r*math.pi)


### FIXED CODE ###

import math
r = float(input())
print("%.10f %.10f"%(r**2*math.pi,2*r*math.pi))
n,m = map(int,input().split())
A=[[] for i in range(n)]
for i in range(n):
	A[i] = list(map(int,input().split()))
b = []
c = list(map(int,'0'*m))
for i in range(m):
	b.append(int(input())) 
for i in range(n):
	for j in range(m):
		c[i] += A[i][j]*b[j]
for i in range(n):		
	print(c[i])


### FIXED CODE ###

n,m = map(int,input().split())
A=[[] for i in range(n)]
for i in range(n):
    A[i] = list(map(int,input().split()))
b = []
c = list(map(int,'0'*n))
for i in range(m):
    b.append(int(input())) 
for i in range(n):
    for j in range(m):
        c[i] += A[i][j]*b[j]
for i in range(n):      
    print(c[i])
group_id = 0
groups = []

def solve(graphs, ps):
    global group_id, groups
    groups = [-1] * (len(ps) + 1)

    for key in range(1, len(ps) + 1):
        if key < len(graphs) and groups[key] == -1:
            group_id += 1
            dfs(graphs, key)

    ans = 0
    for key, value in enumerate(ps, 1):
        if key < len(groups) and value < len(groups) and groups[key] == groups[value]:
            ans += 1
    return ans

def dfs(graphs, key):
    if key >= len(groups):
        return

    global groups
    groups[key] = group_id

    for graph_key in graphs[key]:
        if graph_key < len(groups) and groups[graph_key] == -1:
            dfs(graphs, graph_key)

def main():
    n, m = map(int, input().split())
    ps = list(map(int, input().split()))

    # 隣接リスト作成 (0, n]
    graphs = [[] for i in range(n + 1)]
    for i in range(m):
        x, y = map(int, input().split())
        graphs[x].append(y)
        graphs[y].append(x)

    ans = solve(graphs, ps)
    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

class UnionFind:
    def __init__(self, size):
        self.parent = list(range(size))
        self.rank = [0] * size

    def root(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.root(self.parent[x])
        return self.parent[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return

        if self.rank[x] > self.rank[y]:
            self.parent[y] = x
        else:
            self.parent[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        return self.root(x) == self.root(y)


def main():
    n, m = map(int, input().split())
    ps = list(map(int, input().split()))

    # 1-origin
    union_find = UnionFind(n + 1)
    for i in range(m):
        x, y = map(int, input().split())
        union_find.unite(x, y)

    ans = 0
    for key, value in enumerate(ps, 1):
        if union_find.same(key, value):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()
import sys 
sys.setrecursionlimit(10**6)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
N = int(readline())
K = int(readline())
@lru_cache(None)
def f(N,K):
    if K == -1:
        return 0
    if N < 10:
        if K == 0:
            return 1
        elif K == 1:
            return N
        else:
            return 0
    ans = 0
    q, mod = divmod(N, 10)
    ans += f(q,K) + mod * f(q,K-1) + (9-mod) * f(q-1,K-1) 
    return ans
print(f(N,K))

### FIXED CODE ###

import sys 
from functools import lru_cache
sys.setrecursionlimit(10**6)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
N = int(readline())
K = int(readline())
@lru_cache(None)
def f(N,K):
    if K == -1:
        return 0
    if N < 10:
        if K == 0:
            return 1
        elif K == 1:
            return N
        else:
            return 0
    ans = 0
    q, mod = divmod(N, 10)
    ans += f(q,K) + mod * f(q,K-1) + (9-mod) * f(q-1,K-1) 
    return ans
print(f(N,K))
x, k, d = map(int, input().split())
if x >= 0:
    if x - k * d >= 0:
        print(x - k * d)
    else:
        # 最初に負になってしまうところとその直前を巡回する
        ok, ng = k, 0
        while (ok - ng) > 1:
            mid = (ok + ng) // 2
            if x - mid * d <= 0:
                # いきすぎ
                ok = mid
            else:
                ng = mid
        # ok回目で負にたどり着く？
        rest = k - ok
        if rest % 2 == 0:
            # いまいるところに戻ってこれる
            print(abs(x - ok * d))
        else:
            # 一回正方向にいどうしたもの
            print(x - (ok - 1) * d)
else:
    if x + k * d <= 0:
        print(abs(x + k * d))
    else:
        # 最初に正になるところ
        ok, ng = ok, 0
        while (ok - ng) > 1:
            if x + mid * k >= 0:
                ok = mid
            else:
                ng = mid
        rest = k - ok
        if rest % 2 == 0:
            print(x + ok * d)
        else:
            print(abs(x + (ok - 1) * d))

### FIXED CODE ###

x, k, d = map(int, input().split())
if x >= 0:
    if x - k * d >= 0:
        print(x - k * d)
    else:
        # 最初に負になってしまうところとその直前を巡回する
        ok, ng = k, 0
        while (ok - ng) > 1:
            mid = (ok + ng) // 2
            if x - mid * d <= 0:
                # いきすぎ
                ok = mid
            else:
                ng = mid
        # ok回目で負にたどり着く？
        rest = k - ok
        if rest % 2 == 0:
            # いまいるところに戻ってこれる
            print(abs(x - ok * d))
        else:
            # 一回正方向にいどうしたもの
            print(x - (ok - 1) * d)
else:
    if x + k * d <= 0:
        print(abs(x + k * d))
    else:
        # 最初に正になるところ
        ok, ng = k, 0
        while (ok - ng) > 1:
            mid = (ng + ok) // 2
            if x + mid * d >= 0:
                ok = mid
            else:
                ng = mid
        rest = k - ok
        if rest % 2 == 0:
            print(x + ok * d)
        else:
            print(abs(x + ok * d - d))
# coding: utf-8

s,k = [ input() for i in range(2) ]

count = 0
while s[count]=="1":
    count += 1

if int(k) <= count:
    print(1)
else:
    print(s[count])


### FIXED CODE ###

# coding: utf-8

s,k = [ input() for i in range(2) ]

count = 0
while count != len(s) and s[count]=="1":
    count += 1

if int(k) <= count:
    print(1)
else:
    print(s[count])
import math
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:
        r = (A-C)%math.gcd(B,C)
        if C + r >= B:
            print('Yes')
        else:
            print('No')

### FIXED CODE ###

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')
import collections
n,m = map(int, raw_input().split(' '))
matrix = [raw_input() for _ in range(n)]
dpleft = [[0 for j in range(m)] for i in range(n)]
dpright = [[0 for j in range(m)] for i in range(n)]
dpup = [[0 for j in range(m)] for i in range(n)]
dpdown = [[0 for j in range(m)] for i in range(n)]

for i in range(len(matrix)):
	cumul = 0
	for j in range(len(matrix[i])):
		if matrix[i][j] == '#':
			cumul = 0
		else:
			dpleft[i][j] = cumul
			cumul +=1

	cumul = 0
	for j in range(len(matrix[i]))[::-1]:
		if matrix[i][j] == '#':
			cumul = 0
		else:
			dpright[i][j] = cumul
			cumul +=1

for j in range(len(matrix[0])):
	cumul = 0
	for i in range(len(matrix)):
		if matrix[i][j] == '#':
			cumul = 0
		else:
			dpup[i][j] = cumul
			cumul +=1

	cumul = 0
	for i in range(len(matrix))[::-1]:
		if matrix[i][j] == '#':
			cumul = 0
		else:
			dpdown[i][j] = cumul
			cumul +=1
for i in range(len(matrix)):
	for j in range(len(matrix)):
		if matrix[i][j] == '.':
			m = max(m, 1 + dpleft[i][j] + dpright[i][j] + dpdown[i][j] + dpup[i][j])
print m

### FIXED CODE ###

import collections
n,m = map(int, raw_input().split(' '))
matrix = [list(raw_input()) for _ in range(n)]
dpleft = [[0 for j in range(m)] for i in range(n)]
dpright = [[0 for j in range(m)] for i in range(n)]
dpup = [[0 for j in range(m)] for i in range(n)]
dpdown = [[0 for j in range(m)] for i in range(n)]

for i in range(n):
	cumul = 0
	for j in range(m):
		if matrix[i][j] == '#':
			cumul = 0
		else:
			dpleft[i][j] = cumul
			cumul +=1

	cumul = 0
	for j in range(m-1,-1,-1):
		if matrix[i][j] == '#':
			cumul = 0
		else:
			dpright[i][j] = cumul
			cumul +=1

for j in range(m):
	cumul = 0
	for i in range(n):
		if matrix[i][j] == '#':
			cumul = 0
		else:
			dpup[i][j] = cumul
			cumul +=1

	cumul = 0
	for i in range(n-1,-1,-1):
		if matrix[i][j] == '#':
			cumul = 0
		else:
			dpdown[i][j] = cumul
			cumul +=1
r = 0
for i in range(len(matrix)):
	for j in range(len(matrix[0])):
		if matrix[i][j] != '#':
			r = max(r, 1 + dpleft[i][j] + dpright[i][j] + dpdown[i][j] + dpup[i][j])

print r
n,m=map(int,input().split())
std = [list(map(int,input().split())) for i in range(n)]
chk = [list(map(int,input().split())) for i in range(m)]
for s in std:
  print(min(lambda i:abs(s[0]-chk[i][0])+abs(s[1]-chk[i][1])))

### FIXED CODE ###

n,m=map(int,input().split())
std = [list(map(int,input().split())) for i in range(n)]
chk = [list(map(int,input().split())) for i in range(m)]
for s in std:
  ans=[]
  for i in range(m):
    ans.append([abs(s[0]-chk[i][0])+abs(s[1]-chk[i][1]),i+1])
    ans.sort()
  print(ans[0][1])