Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

def main():
    N, K = map(int, input().split())
    XY = [tuple(map(int, input().split())) for _ in range(N)]
    XY.sort()
    XY = tuple(XY)

    def count(x_min, x_max, y_min, y_max, i, j):
        OK = 0
        # NG = 0
        a = j - i + 1 - K
        for m in range(i, j + 1):
            if y_min <= XY[m][1] <= y_max:
                OK += 1
            # else:
            #     NG += 1
            # if OK >= K:
            #     return True
            # if NG > a:
            #     return False
        if OK >= K:
            return True
        return False

    ans = 10 ** 20
    for i in range(N - 1):
        a = XY[i][0]
        for j in range(i + K - 1, N):
            b = XY[j][0]
            e = b - a
            for k in range(N):
                c = XY[k][1]
                for l in range(N):
                    d = XY[l][1]
                    if c < d:
                        if count(a, b, c, d, i, j):
                            # print ('A')
                            ans = min(ans, e * (d - c))
    print (ans)
    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

#PythonだとTLEする
N, K = map(int, input().split())
X = [0] * N
Y = [0] * N
for i in range(N):
    x, y = map(int, input().split())
    X[i] = x
    Y[i] = y

def count(x_min, x_max, y_min, y_max):
    cnt = 0
    for i in range(N):
        if x_min <= X[i] <= x_max and y_min <= Y[i] <= y_max:
            cnt += 1
    return cnt

ans = 10 ** 20
for i in range(N):
    for j in range(N):
        for k in range(N):
            for l in range(N):
                # print ('i, j , k, l = ', i, j, k, l)
                if X[i] < X[j] and Y[k] < Y[l]:
                    if count(X[i], X[j], Y[k], Y[l]) >= K:
                        # print ('A')
                        ans = min(ans, (X[j] - X[i]) * (Y[l] - Y[k]))
print (ans)
### BUGGY CODE ###

x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
l1=[]
#print(a,end=" a\n")
#print(b,end=" b\n")
for i in a:
  for j in b:
    # print(i,j)
    l1.append(i+j)
l1.sort(reverse=True)
#print(l1)
l1=l1[:min(len(l1),k)]
l2=[]
for i in l1:
  for j in c:
    l2.append(i+j)
l2.sort(reverse=True)
#print(l2)
print("\n".join(map(str,l2[:k])))


### FIXED CODE ###

import sys
input=sys.stdin.readline
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
l1=sorted([i+j for i in a for j in b],reverse=True)[:k]
l2=sorted([i+j for i in l1 for j in c],reverse=True)[:k]
for i in l2:
  print(i)
### BUGGY CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(int(input()))
temp = [0]
for s_ in s:
    ans = temp.copy()
    for t in ans:
        tt = t + s_
        temp.append(tt)
temp = list(set(temp))
temp = [t for t in temp if t%10 != 0]
temp.sort()
if len(temp) > 0:
    print(temp[-1])
else:
    print(0)

### FIXED CODE ###

n = int(input())
s = []
for _ in range(n):
    s.append(int(input()))
sum_s = sum(s)
if sum_s % 10 != 0:
    ans = sum_s
else:
    s_10 = [i for i in s if (i%10 != 0)]
    s_10.sort()
    if len(s_10) > 0:
        ans = sum_s - s_10[0]
    else:
        ans = 0
print(ans)
### BUGGY CODE ###

N = int(input())
list_A = list(map(int, input().split()))

if 0 in list_A:
    print(0)
    exit()

result = 1
for a in list_A:
    result *= a

if result > 1e18:
    print(-1)
else:
    print(result)

### FIXED CODE ###

N = int(input())
list_A = list(map(int, input().split()))

if 0 in list_A:
    print(0)
    exit()

result = 1
for a in list_A:
    result *= a
    if result > 1e18:
        print(-1)
        exit()

print(result)
### BUGGY CODE ###

# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque

INF = 1 << 50



def run():
    K = int(input())
    left = 7 % K
    right = 1 % K
    next_add = 1
    if not K % 2:
        print(-1)
        return None
    ans = 1
    dic = {}
    while True:
        if not left * right % K:
            print(ans)
            return None
        else:
            dic
            next_add = next_add * 10 % K
            right = (right + next_add) % K
            ans += 1
            if right == 1:
                print(-1)
                return

if __name__ == "__main__":
    run()

### FIXED CODE ###

# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque

INF = 1 << 50



def run():
    K = int(input())
    left = 7 % K
    right = 1 % K
    next_add = 1
    if not K % 2:
        print(-1)
        return None
    ans = 1
    right_set = set()
    while True:
        if not left * right % K:
            print(ans)
            return None
        else:
            right_set.add(right)
            next_add = next_add * 10 % K
            right = (right + next_add) % K
            ans += 1
            if right in right_set:
                print(-1)
                return

if __name__ == "__main__":
    run()
### BUGGY CODE ###

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

cnt=[0]*60
p=10**9+7
for m in a:
    b=bin(m)
    l=len(b)-2
    #print(b)
    for i in range(l):
        cnt[i]+=int(b[-i-1])
    #kei=m
    #for i in range(100):
    #    cnt[i]+=kei%2
    #    kei//=2
    #    if(kei==0):
    #        break

#print(cnt)

lis=[]
jou=1
for i in range(60):
    lis.append(jou)
    jou*=2
    jou%=p

ans=0

for i in range(60):
    ans+=(lis[i]%p)*(cnt[i]%p)*((n-cnt[i])%p)
    ans%=p

print(ans)

### FIXED CODE ###

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

cnt=[0]*60
p=10**9+7
for m in a:
    #b=bin(m)
    #l=len(b)-2
    #print(b)
    for i in range(60):
        if((m>>i) & 1):
            cnt[i]+=1
    #for i in range(l):
    #    cnt[i]+=int(b[-i-1])
    #kei=m
    #for i in range(100):
    #    cnt[i]+=kei%2
    #    kei//=2
    #    if(kei==0):
    #        break

#print(cnt)

lis=[]
jou=1
for i in range(60):
    lis.append(jou)
    jou*=2
    jou%=p

ans=0

for i in range(60):
    ans+=(lis[i]%p)*(cnt[i]%p)*((n-cnt[i])%p)
    ans%=p

print(ans)
### BUGGY CODE ###

from heapq import heappush, heappop, heapify
from collections import defaultdict
N,M,S,T=[int(a) for a in input().split(" ")]
S,T=S-1,T-1
UVAB = [[int(a) for a in input().split(" ")] for i in range(M)]
dic = defaultdict(list)
INF = 10**20

for u, v, a, b in UVAB:
    dic[u-1].append((v-1,a))
    dic[v-1].append((u-1,a))
    dic[u+N-1].append((v+N-1,b))
    dic[v+N-1].append((u+N-1,b))

ans = []
for i in list(range(N))[::-1]:
    dic[i].append((i+N,0))
    dic_dist = defaultdict(lambda: INF)
    dic_dist[S] = 0
    q = [(0, S)]
    while(q):
        d0, node = heappop(q)
        if dic_dist[node] < d0:
            continue
        for dst, d1 in dic[node]:
            if dic_dist[dst] > d0+d1:
                dic_dist[dst] = d0+d1
                heappush(q, (d0+d1, dst))
    ans.append(10**15-dic_dist[T+N])

for line in ans[::-1]:
    print(line)


### FIXED CODE ###

import numpy as np
INF=10**20
N,M,S,T=[int(a) for a in input().split(" ")]
UVAB=[[int(a) for a in input().split(" ")] for i in range(M)]

def dijkstra(S, N, paths):
    from heapq import heappush,heappop
    q=[(0,S)]
    shortest=[INF]*N
    shortest[S]=0
    while len(q)>0:
        d0, src=heappop(q)
        if d0>shortest[src]:
            continue
        for dst, d1 in paths[src]:
            if d0+d1<shortest[dst]:
                shortest[dst]=d0+d1
                heappush(q, (d0+d1, dst))
    return np.array(shortest)

paths_yn=[[] for _ in range(N)]
paths_sn=[[] for _ in range(N)]
for u,v,a,b in UVAB:
    paths_yn[u-1].append((v-1,a))
    paths_yn[v-1].append((u-1,a))
    paths_sn[u-1].append((v-1,b))
    paths_sn[v-1].append((u-1,b))
shortest_yn = dijkstra(S-1, N, paths_yn)
shortest_sn = dijkstra(T-1, N, paths_sn)

totals = 10**15-(shortest_yn+shortest_sn)
for a in np.maximum.accumulate(totals[::-1])[::-1]:
    print(int(a))
### BUGGY CODE ###

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N,M,K = list(map(int,input().split(" ")))

ans = 0
for i in range(0,N):
    for j in range(0,M):
        mul = 2
        if i == 0 or j == 0:
            mul = 1

        ans += mul * (N -i) * (M -j) * (i+j)

ans *= combinations_count(N*M-2,K-2)
ans %= 10**9 + 7
print(ans)

### FIXED CODE ###

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N,M,K = list(map(int,input().split(" ")))

ans = 0
for i in range(0,N):
    for j in range(0,M):
        mul = 2
        if i == 0 or j == 0:
            mul = 1

        ans += mul * (N -i) * (M -j) * (i+j)

ans *= combinations_count(N*M-2,K-2)
ans %= 10**9 + 7
print(ans)
### BUGGY CODE ###

import sys, string
alpha = 'abcdefghijklmnopqrstuvwxyza'
t = string.maketrans(alpha[:-1], alpha[1:])
for s in sys.stdin:
  while not('the' in s or 'this' in s or 'than' in s):
    s = s.translate(t)
  print s

### FIXED CODE ###

import sys, string
alpha = 'abcdefghijklmnopqrstuvwxyza'
tbl = string.maketrans(alpha[:-1], alpha[1:])
for s in sys.stdin:
  while not('the' in s or 'this' in s or 'that' in s):
    s = s.translate(tbl)
  print s[:-1]
### BUGGY CODE ###

from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    n, a, b = map(int, input().split())
    l = [int(input()) for i in range(n)]
    q = []
    for i in l:
        heappush(q, -i)
    cnt = 0
    while True:
        nq = []
        v = -heappop(q)
        if v-a > 0:
            heappush(nq, -(v-a))
        for i in q:
            if -i-b > 0:
                heappush(nq, -(-i-b))
        cnt += 1
        if not nq:
            break
        else: q=nq
    print(cnt)


resolve()

### FIXED CODE ###

import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    # https://qiita.com/drken/items/97e37dd6143e33a64c8c#3-%E3%82%81%E3%81%90%E3%82%8B%E5%BC%8F%E4%BA%8C%E5%88%86%E6%8E%A2%E7%B4%A2%E3%81%AE%E3%81%95%E3%82%89%E3%81%AA%E3%82%8B%E5%88%A9%E7%82%B9

    n,a,b=map(int,input().split())
    h=[int(input()) for _ in range(n)]
    def is_ok(t):
        cnt=0
        for i in h:
            i-=b*t
            if i>0:
                cnt+=math.ceil(i / (a-b))
        return cnt<=t

    def bin_search_meguru():
        """
        初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
        まずis_okを定義すべし
        ng, okは,とり得る最小の値-1,とり得る最大の値+1
        """
    
        # 適当にいじる
        ng = 0  # ind=0が条件を満たすこともあるため
        ok = 10**18  # ind=len(a)-1が条件を満たさないこともあるため
    
        # いじらない
        # okとngのどちらが大きいかわからないことを考慮
        while (abs(ok - ng) > 1):
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok
    print(bin_search_meguru())
    

    
resolve()
### BUGGY CODE ###

import copy
S = list(input())
T = list(input())
m, n = len(S), len(T)
C = [[[] for j in range(n+1)] for i in range(m+1)]
for i in range(m):
    for j in range(n):
        if S[i] == T[j]:
            Cij = copy.copy(C[i][j])
            Cij.append(S[i])
            C[i+1][j+1] = Cij
        elif len(C[i+1][j]) >= len(C[i][j+1]):
            C[i+1][j+1] = C[i+1][j]
        else:
            C[i+1][j+1] = C[i][j+1]
print(''.join(C[m][n]))


### FIXED CODE ###

S = input()
T = input()
m, n = len(S), len(T)
C = [[0 for j in range(n+1)] for i in range(m+1)]
for i in range(m):
    for j in range(n):
        if S[i] == T[j]:
            C[i+1][j+1] = C[i][j] + 1
        else:
            C[i+1][j+1] = max(C[i][j+1], C[i+1][j])
l = C[m][n]
X = ''
while l:
    if S[m-1] == T[n-1]:
        X = S[m-1]+X
        m -= 1
        n -= 1
        l -= 1
    elif C[m][n] == C[m-1][n]:
        m -= 1
    else:
        n -= 1
print(X)
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline
    from collections import deque

    N = int(input())
    # i-indexed
    A = [deque() for _ in range(N+1)]
    for i in range(1,N+1):
        for j in input().split():
            A[i].append(int(j))

    def is_not_empty():
        for x in A:
            if len(x) != 0:
                return True
        return False

    answer = 0
    while is_not_empty():
        played = set()
        for i in range(1,N+1):
            if i in played:
                continue
            if len(A[i]) == 0:
                continue
            enemy = A[i].popleft()
            ME = A[enemy].popleft()
            if ME == i and not(enemy in played):
                played.add(ME)
                played.add(enemy)
            else:
                A[i].appendleft(enemy)
                A[enemy].appendleft(ME)
        if len(played) == 0:
            print(-1)
            exit()
        answer += 1

    print(answer)

if __name__ == '__main__':
    main()

### FIXED CODE ###

# O(N)
def is_not_empty(A):
    for x in A:
        if x:
            return True
    return False

def main():
    import sys
    input = sys.stdin.readline
    from collections import deque

    N = int(input())
    # 1-indexed
    A = [deque() for _ in range(N+1)]
    # O(N^2)
    for i in range(1,N+1):
        for j in input().split():
            A[i].append(int(j))

    # 当日の参加者
    today = set()
    # 初日
    for i in range(1,N+1):
        # 既に参加した人はダメ
        if i in today:
            continue
        enemy = A[i].popleft()
        ME = A[enemy].popleft()
        if ME == i and not(enemy in today):
            today.add(ME)
            today.add(enemy)
        else:
            A[i].appendleft(enemy)
            A[enemy].appendleft(ME)
    # 初日に誰も試合できなかったとき
    if not today:
        print(-1)
        exit()

    # 前日の参加者
    yesterday = today
    # 日数
    answer = 1
    while is_not_empty(A):
        today = set()
        # 前日に試合した人は必ず次の日に試合する
        for i in yesterday:
            if not A[i]:
                continue
            if i in today:
                continue
            enemy = A[i].popleft()
            ME = A[enemy].popleft()
            if ME == i and not(enemy in today):
                today.add(ME)
                today.add(enemy)
            else:
                A[i].appendleft(enemy)
                A[enemy].appendleft(ME)
        if not today:
            print(-1)
            exit()
        answer += 1
        yesterday = today

    print(answer)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp=[[0]*m for _ in range(n)]
sum=[[0]*m for _ in range(n)]
mod=10**9+7
ans=0
for i in range(n):
  if s[i]==t[0]:
    dp[i][0]=1
  else:
    dp[i][0]=0
  ans+=dp[i][0]  
  sum[i][0]=sum[i-1][0]+dp[i][0]
for i in range(m):
  if t[i]==s[0]:
    dp[0][i]=1
  else:
    dp[0][i]=0
  ans+=dp[0][i]
  sum[0][i]=sum[0][i-1]+dp[0][i]
for i in range(1,n):
  for j in range(1,m):
    if s[i]==t[j]:
      dp[i][j]=(sum[i-1][j-1]+1)%mod
    else:
      dp[i][j]=0
    sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j])%mod
    ans+=dp[i][j]
    ans%=mod
print((ans-dp[0][0]+1)%mod)

### FIXED CODE ###

n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp=[[0]*m for _ in range(n)]
sum=[[0]*m for _ in range(n)]
mod=10**9+7
for i in range(n):
  if s[i]==t[0]:
    dp[i][0]=1
  else:
    dp[i][0]=0
for i in range(m):
  if t[i]==s[0]:
    dp[0][i]=1
  else:
    dp[0][i]=0
sum[0][0]=dp[0][0]
for i in range(1,n):
  sum[i][0]=sum[i-1][0]+dp[i][0]
for i in range(1,m):
  sum[0][i]=sum[0][i-1]+dp[0][i]
for i in range(1,n):
  for j in range(1,m):
    if s[i]==t[j]:
      dp[i][j]=(sum[i-1][j-1]+1)%mod
    else:
      dp[i][j]=0
    sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j])%mod
ans=0
for i in range(n):
  for j in range(m):
    ans+=dp[i][j]
    ans=ans%mod
print((ans+1)%mod)
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline
    N, W = map(int, input().split())
    wv = [tuple(map(int, input().split())) for i in range(N)]

    dp = [-1]*(W+1)
    dp[0] = 0
    for w, v in wv:
        for j in range(W-1, -1, -1):
            if dp[j] >= 0 and j+w <= W:
                dp[j+w] = max(dp[j+w], dp[j] + v)

    print(max(dp))


main()


### FIXED CODE ###

def main():
    N, W = map(int, input().split())
    wv = [tuple(map(int, input().split())) for i in range(N)]

    dp = [-1]*(W+1)
    dp[0] = 0
    for w, v in wv:
        for j in range(W-1, -1, -1):
            if dp[j] >= 0 and j+w <= W:
                dp[j+w] = max(dp[j+w], dp[j] + v)

    print(max(dp))


main()
### BUGGY CODE ###

_ = input()
inp = map(int, input().split())

of = False
re = 1

for a in inp:
    re *= a


if (re - 1) // (10**18) > 0:
    re = -1

print(re)


### FIXED CODE ###

_ = input()
inp = list(map(int, input().split()))

re = 1


for a in inp:
    re = re * a
    if re > (10**18):
        of = True
        re = -1
        break


for a in inp:
    if a == 0:
        re = 0


print(re)
### BUGGY CODE ###

import sys

import numpy as np

n, m = map(int, input().split())
links = [[] for _ in range(n)]
for line in sys.stdin:
    s, t = map(int, line.split())
    s -= 1
    t -= 1
    links[s].append(t)

not_omitted = np.zeros(n, dtype=np.float64)
for j in range(n - 2, -1, -1):
    exp = not_omitted[links[j]]
    not_omitted[j] = exp.mean() + 1

ans = not_omitted[0]

for i in range(n - 1):
    expected = not_omitted.copy()

    exp = expected[links[i]]
    if exp.size == 1:
        expected[i] = exp.mean() + 1
    else:
        expected[i] = (exp.sum() - exp.max()) / (exp.size - 1) + 1

    for j in range(i - 1, -1, -1):
        exp = expected[links[j]]
        expected[j] = exp.mean() + 1

    ans = min(ans, expected[0])

print(ans)


### FIXED CODE ###

import sys

n, m = map(int, input().split())
links = [set() for _ in range(n)]
counts = [0] * n
for line in sys.stdin:
    s, t = map(int, line.split())
    s -= 1
    t -= 1
    links[s].add(t)
    counts[s] += 1

not_omitted = [0.0] * n
exp_get = not_omitted.__getitem__
for j in range(n - 2, -1, -1):
    not_omitted[j] = sum(map(exp_get, links[j])) / counts[j] + 1

ans = 1e6

for i in range(n - 1):
    expected = [0.0] * n
    expected[i + 1:] = not_omitted[i + 1:]
    e_get = expected.__getitem__

    if counts[i] == 1:
        expected[i] = sum(map(e_get, links[i])) / counts[i] + 1
    else:
        exp = list(map(e_get, links[i]))
        expected[i] = (sum(exp) - max(exp)) / (counts[i] - 1) + 1

    for j in range(i - 1, -1, -1):
        expected[j] = sum(map(e_get, links[j])) / counts[j] + 1

    ans = min(ans, expected[0])

print(ans)
### BUGGY CODE ###

N = int(input())#数字
A = list(map(int, input().split()))

ans = 0
for i in range(1, N + 1):
    B = A[: i - 1] + A[i:]
    #print(B)
    for j in set(B):
        C = B.count(j)
        if C >= 2:
            ans += C * (C - 1) / 2
    print(int(ans))
    ans = 0

### FIXED CODE ###

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

import collections
C = collections.Counter(a)

#logging.debug(C)

sum=0
for v in list(C.values()):
	sum+=v*(v-1)//2
 
for k in range(n):
	x = C[a[k]]
	print(sum-(x*(x-1)//2)+((x-1)*(x-2)//2))
### BUGGY CODE ###

N,K = map(int,input().split())
A = [int(i) for i in input().split()]

ans = 0

minA = min(A)

for i in range(len(A)):
        if A[i] == minA:
                A[i] = 0
        else:
                A[i] = 1

while 1 in A:
        if len(A) <= K:
                ans += 1
                break
        if A[0] == 0:
                if A[1] == 0:
                        A = A[1:]
                elif 0 in A[1:1+K]:
                        A[K] = 0
                        A = A[K:]
                        ans += 1
                else:
                        A[K-1] = 0
                        A = A[K-1:]
                        ans += 1
        else:
                A = A[K-1:]
                ans += 1
print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
A = [int(i) for i in input().split()]

print((N-1)//(K-1)+((N-1)%(K-1)!=0))
### BUGGY CODE ###

t = int(input())
abcd_list = [[int(i) for i in input().split()] for _ in range(t)]

for i in range(len(abcd_list)):
    a, b, c, d = abcd_list[i]
    _a = a
    is_ok = True
    for j in range(10000000):
        if d < b:
            is_ok = False
            break
        
        if _a - b > c:
            _a = _a - (((_a - c) // b) - 1) * b
        _a = _a - b
        if _a < 0:
            is_ok = False
            break
        if _a <= c:
            _a += d
    if is_ok:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
t = int(input())
abcd_list = [[int(i) for i in input().split()] for _ in range(t)]

for i in range(len(abcd_list)):
    a, b, c, d = abcd_list[i]
    if b > a:
        print("No")
        continue
    if b > d:
        print("No")
        continue
    if c > b:
        print('Yes')
        continue
    g = gcd(b, d)
    max_mod_b = b - g + a % g
    if max_mod_b > c:
        print('No')
    else:
        print("Yes")
### BUGGY CODE ###

n=int(input())
h=list(map(int,input().split()))
a=1
mx=0
p=0
while a!=n:
    if h[a-1]>=h[a]:
        p+=1
        a+=1
    else:
        if p>mx:
            mx=p
            a+=1
            p=0
print(-min(-mx,-p))

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
a=0
mx=0
p=0
while a!=n-1:
    if h[a]>=h[a+1]:
        p+=1
        a+=1
    else:
        if p>mx:
            mx=p  
            a+=1
            p=0
        else:
            a+=1
            p=0
print(-min(-mx,-p))
### BUGGY CODE ###

from collections import deque

S = deque([x for x in input()])
Q = int(input())
for _ in range(Q):
    inp = input()
    if len(inp) == 1:
        T = int(inp)
        S.reverse()
    else:
        T, F = map(int, inp.split()[:2])
        C = inp.split()[-1]
        if F == 1:
            S.appendleft(C)
        else:
            S.append(C)

print("".join(S))


### FIXED CODE ###

from collections import deque

S = deque([x for x in input()])
Q = int(input())
switch = 0
for _ in range(Q):
    inp = input()
    if len(inp) == 1:
        T = int(inp)
        if switch:
            switch = 0
        else:
            switch = 1
    else:
        T, F = map(int, inp.split()[:2])
        C = inp.split()[-1]
        if F == 1:
            if switch:
                S.append(C)
            else:
                S.appendleft(C)
        else:
            if switch:
                S.appendleft(C)
            else:
                S.append(C)
if switch:
    print("".join(list(S)[::-1]))
else:
    print("".join(S))