Harryxun/stf_run huggingface dataset:
k = int(inut())
a, b = map(int, input().split())

for i in range(b-a):
  if (a + i) % k == 0:
    print("OK")
  else:
    print("NG")

### FIXED CODE ###

k = int(input())
a, b = map(int, input().split())
count = 0
 
for i in range(b-a+1):
  if (a + i) % k == 0:
    count += 1
  
print("OK" if count > 0 else "NG")
S=input()
N=len(S)
S1=S[:(N-1)//2]
S2=S[(N+1)//2:]
if S==S[::-1] and S1=S1[::-1] and S2==S2[::-1]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S=input()
N=len(S)
S1=S[:(N-1)//2]
S2=S[(N+1)//2:]
if S==S[::-1] and S1==S1[::-1] and S2==S2[::-1]:
  print("Yes")
else:
  print("No")
a, b, c = map(int, input().split())
if (a+b)>=c:
	return c+b
else:
	return a+2*b

### FIXED CODE ###

a, b, c = map(int, input().split())
if (a+b)>=c:
	print(c+b)
else:
	print(a+2*b+1)
#D
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
i=0
l=0
for k in range(m-1):
    if i==n-1:
        for j in range(n):
            a[j]=a[j]//2
    elif a[i]//2<a[i+1]:
        i+=1
    else:
        for j in range(i+1):
            a[j]=a[j]//2
            l+=1
for j in range(m-l):
    a[j]=a[j]//2
print(sum(a))

### FIXED CODE ###

#D heapq
import heapq
def mainasu(n):
    return n*(-1)
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(mainasu,a))
b.sort()
for i in range(m):
    c=heapq.heappop(b)
    if c%2==0:
        heapq.heappush(b,c//2)
    else:
        heapq.heappush(b,c//2+1)
print((-1)*sum(b))
s = str(input())

if s[0] != A:
    print('WA')
    break
else:
    for i in range(len(s)-1):
        if s[i] == C:
            s = s[1:i-1] + s[i+1:]
            break
    if s.islower() == True:
        print('AC')
    else:
        print('WA')

### FIXED CODE ###

s = str(input())
if s[0] == 'A' and s[2:-1].count('C') == 1 and (s[1:s.find('C')]+s[s.find('C')+1:]).islower():
    print('AC')
else:
    print('WA')
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
anslist = []

for i in range(1,n-1):
  if a[i] < 0:
    anslist.append([a[-1], a[i]])
    a[-1] -= a[i]
  else:
    anslist.append([a[0], a[i]])
    a[0] -= a[i]
anslist.append([a[-1], a[0]])
ans = a[-1]-a[0]
print(ans)
for i in range(len(anslist)):
  print(anslist[i][0], anslist[i][1])
    
  
      


### FIXED CODE ###

n,k=map(int,input().split())
if k == 1:
  print(0)
else:
  print(n-k)
from math import gcd
n, k = map(int, input().split())
a = list(map(int, input().split()))
g = 0
for x in a:
    g = gcd(g, x)
print(k <= max(a) and k % g == 0 and "POSSIBLE" or "IMPOSSIBLE")

### FIXED CODE ###

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

n, k = map(int, input().split())
a = list(map(int, input().split()))
g = a[0]
for x in a:
    g = gcd(g, x)
print(("IMPOSSIBLE", "POSSIBLE")[k <= max(a) and k % g == 0])
a,b = map(int,input().split())
if a+b>=10:
  print(error)
else:
  print(a+b)

### FIXED CODE ###

a,b = map(int,input().split())
if a+b>=10:
  print('error')
else:
  print(a+b)
n = int(input())
a = [i in int(input().split()))]
for  i in range(n):
    v  = a[i]
    j = i-1
    while a[j]>a[j+1] and j>0:
        a[j+1] = a[j]
        a[j] = v
        j -=1
    print(*a)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
for  i in range(n):
    v  = a[i]
    j = i-1
    while a[j]>v and j>=0:
        a[j+1] = a[j]
        j -=1

    a[j+1] = v
    print(*a)
N = input()
import math
count = 0
for i in range(1,N+1):
    if int(math.log10(i)) %2 ==1:
        count+= 1
print(count)

### FIXED CODE ###

N = int(input())
import math
count = 0
for i in range(1,N+1):
    if int(math.log10(i)) %2 ==0:
        count+=1
print(count)
n=int(input())
h=list(map(int,input().split()))
x=[]
y=0
for i in range (n-1):
  if h[i]>=h[i+1]:
    y+=1
    x.append(y)
    elif h[i]<h[i+1] :
    x.append(y)
    y=0
print(max(x))
  

### FIXED CODE ###

S=input()
T=input()
x=0
for i in range(3):
  if S[i]==T[i]:
    x=x+1
  else:
    x=x
print(x)
n,k=map(int,input().split())

if k=1:
    print('0')

else:

    ans=n-k
    print(ans)	

### FIXED CODE ###

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

if k==1:
    print('0')

else:

    ans=n-k
    print(ans)
import heapq

n = int(input())
#A = [[int(i) for i in input().split()] for i in range(n)]
h = []
DP = {}
heapq.heappush(h,(0,0))
c = 0
while(len(DP)<n):
    tmp = heapq.heappop(h)
    if tmp[1] in DP:
        continue
    c += tmp[0]
    DP[tmp[1]] = 1
    for i,j in enumerate(A[tmp[1]]):
        if j > 0 and not i in DP:
            heapq.heappush(h,(j,i))
print(c)


### FIXED CODE ###

import heapq

n = int(input())
A = [[int(i) for i in input().split()] for i in range(n)]
h = []
DP = {}
heapq.heappush(h,(0,0))
c = 0
while(len(DP)<n):
    tmp = heapq.heappop(h)
    if tmp[1] in DP:
        continue
    c += tmp[0]
    DP[tmp[1]] = 1
    for i,j in enumerate(A[tmp[1]]):
        if j > -1 and not i in DP:
            heapq.heappush(h,(j,i))
print(c)
from math import gcd
import sys

for line in sys.stdin:
    a, b = list(map(int, line.split()))
    print("{0} {1}".format(gcd(a, b), int((a * b) / gcd(a, b))))

### FIXED CODE ###

import sys

def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        x, y = y, x % y
    return x

for line in sys.stdin:
    a, b = list(map(int, line.split()))
    print("{0} {1}".format(gcd(a, b), int((a * b) / gcd(a, b))))
n, m, c = map(int, input().split())
b = map(int, input().split())
count = 0
 
for i in range(n):
  a = map(int, input().split())
  for j in range(m):
    if 0 < (a[j] * b[j] + c):
      count += 1
print(count)

### FIXED CODE ###

n, m, c = map(int, input().split())
b = list(map(int, input().split()))
count = 0
 
for i in range(n):
  a = list(map(int, input().split()))
  p = c
  for j in range(m):
  	p += a[j] * b[j]
  if 0 < p:
    count += 1
print(count)
def solve_dp(p):
    if p == 0:
        dp[0] = 0
    elif p == 1:
        dp[1] = abs(h[1] - h[0])
    elif p >= 2 and p <= N - 1:
        if abs(h[p] - h[p-1]) > abs(h[p] - h[p-2]):
            dp[p] = abs(h[p] - h[p-2]) + dp[p-2]
        else:
            dp[p] = abs(h[p] - h[p-1]) + dp[p-1]
    else:
        return

    p += 1
    solve_dp(p)

N = int(input())
h = [int(x) for x in input().split()]

dp = [0] * N
solve_dp(0)

print(dp[N-1])


### FIXED CODE ###

def solve_dp(p):
    i = 0
    while i < N:
        if p == 0:
            dp[0] = 0
        elif p == 1:
            dp[1] = abs(h[1] - h[0])
        elif p >= 2 and p <= N - 1:
            if abs(h[p] - h[p-1]) + dp[p-1] > abs(h[p] - h[p-2]) + dp[p-2]:
                dp[p] = abs(h[p] - h[p-2]) + dp[p-2]
            else:
                dp[p] = abs(h[p] - h[p-1]) + dp[p-1]
        else:
            return

        p += 1
        i += 1

N = int(input())
h = [int(x) for x in input().split()]

dp = [0] * N
solve_dp(0)

print(dp[N-1])
n, k = map(int, raw_input().split())
plist = map(int, raw_input().split())

exp_list = [(p + 1) / 2.0 for p in plist]
print max(sum(exp_list[i:i+k]) for i in xrange(n-k))


### FIXED CODE ###

n, k = map(int, raw_input().split())
plist = map(int, raw_input().split())

exp_list = [(p + 1) / 2.0 for p in plist]
ans = s = sum(exp_list[:k])
for i in xrange(n - k):
    s = s - exp_list[i] + exp_list[i + k]
    ans = max(ans, s)

print ans
s=input()
if "".join(sorted(s)=="abc":
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s=input()
if "".join(sorted(s))=="abc":
  print("Yes")
else:
  print("No")
import sys
import numpy as np


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


def main():
    n = int(input())
    a = [int(e) for e in input().split()]
    va = np.array(a)
    m = np.identity(n, dtype=int)
    for i in range(n):
        if i < n - 1:
            m[i][i + 1] = 1
        else:
            m[i][0] = 1
    vx = np.linalg.solve(m, va).astype(np.int) * 2
    print(*vx)


main()


### FIXED CODE ###

import sys
import numpy as np


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


def main():
    n = int(input())
    a = [int(e) for e in input().split()]
    x = [0 for _ in range(n)]
    x[0] = sum(a) - (sum(a[1:n:2]) * 2)
    for i in range(2, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    x[1] = sum(a) - (sum(a[2:n:2]) * 2)
    for i in range(3, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    print(*x)


main()
a = input()

if (isupper(a)):
  print("A")
else:
  print("a")

### FIXED CODE ###

a = input()

if (a.isupper()):
  print("A")
else:
  print("a")
A, B = [int(v) for v in input().split(' ')]

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

def cf(x1, x2):
    array = [1]
    for i in primes(gcd(x1, x2)):
        if x1 % i == 0 and x2 % i == 0:
            array.append(i)
    return array 

def cf_count(x1, x2):
    count = 1
    n = gcd(x1, x2)
    for i in primes(n):
        if x1 % i == 0 and x2 % i == 0:
            count += 1
    return count

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

print(cf_count(A, B))
            


### FIXED CODE ###

A, B = [int(v) for v in input().split(' ')]

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2

    i = 3
    while i * i <= n:
        if n % i == 0:
            a.append(i)
            n //= i
        else:
            i += 2

    if n != 1:
        a.append(n)
    return a

a_fact = prime_factorize(A)
b_fact = prime_factorize(B)

print(len(set(a_fact) & set(b_fact)) + 1)
def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**10)
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #r = [int(stdin.readline()) for i in range(3)]
    
    a = list(map(int, r.split()))
    n = a[0]
    k = a[1]
    s = a[2]

    res = [s+1]*n
    for i in range(k):
        res[i] = s
    print(*res)

    #'Yes', 'No', 'YES', 'NO', ':(', 'Yay!'
    #res = 0
    #a, b = map(int, r.split())
    #print()

if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**9)
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #r = [int(stdin.readline()) for i in range(3)]
    
    a = list(map(int, r.split()))
    n = a[0]
    k = a[1]
    s = a[2]

    tmp = 0
    if s == 10**9:
        tmp = 1
    else:
        tmp = 10**9
    res = [tmp]*n
    for i in range(k):
        res[i] = s
    print(*res)

    #'Yes', 'No', 'YES', 'NO', ':(', 'Yay!'
    #res = 0
    #a, b = map(int, r.split())
    #print()

if __name__ == '__main__':
    main()
N = int(input())
P = [map(int, input().split())]

c = 0
for i in range(N-2):
  if P[i] < P[i+1] <= P[i+2]:
    c += 1
  elif P[i+2] < P[i+1] <= P[i]:
    c += 1
  else:
    pass
  
print(c)
  


### FIXED CODE ###

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

c = 0
for i in range(N-2):
  if P[i] < P[i+1] <= P[i+2]:
    c += 1
  elif P[i+2] < P[i+1] <= P[i]:
    c += 1
  
print(c)
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p=sorted(p)
q=sorted(q)
r=sorted(r)
p=p[(a-x):]
q=q[(b-y):]
res=sum(p)+sum(q)
tp=0
tq=0
tr=c-1
while(p[tp]<r[tr] or q[tq]<r[tr]):
  if(p[tp]<q[tq]):
    res+=r[tr]-p[tp]
    tp+=1
  else:
    res+=r[tr]-q[tq]
    tq+=1
  tr-=1
print(res)

### FIXED CODE ###

x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p=sorted(p)
q=sorted(q)
r=sorted(r)
p=p[(a-x):]
q=q[(b-y):]
res=sum(p)+sum(q)
tp=0
tq=0
tr=c-1
while 1:
  if(tr<0 ):
    break
  if(tp>=x):
    pp=100000000000
  else:
    pp=p[tp]
  if(tq>=y):
    qq=100000000000
  else:
    qq=q[tq]

  if(pp>r[tr] and qq>r[tr]):
    break
  if(pp<qq ):
    res+=r[tr]-pp
    tp+=1
  else:
    res+=r[tr]-qq
    tq+=1
  tr-=1
print(res)
n,m = map(int,input().split())
q = [list(map(int, input().split())) for i in range(m)]
ans = 0

for s in range(2**n): #スイッチのon/offの状態の総当たり（2**n通り）
    judge = True
    for i in range(m): #電球1つずつに対して
        cnt=0
        for j in range(1,len(q[i])): #sの総当たりでqに当てはまるものを探す。kはforを1からにすれば無視できる。
            w=q[i][j]
            if s >> (w-1) &1 ==1: #sをw-1回シフトさせて(w-1)個目のスイッチがonか判定
                cnt+=1 #onになっているスイッチの個数をカウント
        if cnt % 2 != p[i]: #スイッチの個数を2で割った余りがpiに等しいか判定
            judge = False
    if judge:
        ans += 1

print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
q = [list(map(int, input().split())) for i in range(m)]
p= list(map(int, input().split()))
ans = 0
 
for s in range(2**n): #スイッチのon/offの状態の総当たり（2**n通り）
    judge = True
    for i in range(m): #電球1つずつに対して
        cnt=0
        for j in range(1,len(q[i])): #sの総当たりでqに当てはまるものを探す。kはforを1からにすれば無視できる。
            w=q[i][j]
            if s >> (w-1) &1 ==1: #sをw-1回シフトさせて(w-1)個目のスイッチがonか判定
                cnt+=1 #onになっているスイッチの個数をカウント
        if cnt % 2 != p[i]: #スイッチの個数を2で割った余りがpiに等しいか判定
            judge = False
    if judge:
        ans += 1
 
print(ans)
k,s=map(int,input().split())

asn=o

for i in range(k+1):
  for j in range(k+1):
    if 0<=s-i-j<=k: ans+=1

print(ans)

### FIXED CODE ###

K,S=map(int, input().split())
ans=0

for i in range(K+1):
  for j in range(K+1):
    if 0<=S-i-j<=K :
      ans+=1
print(ans)
n=int(input())
a=list(map(int,input().split()))
a.sort()
CNT=[]
cnt=0
for i in range(n-1):
  for j in range(n-i):
    if a[i+j]-a[i]<2:
      cnt+=1
    else:
      CNT.append(cnt)
      cnt-=cnt
      break
print(max(CNT))

  


### FIXED CODE ###

import collections
import sys
n=int(input())
a=list(map(int,input().split()))
b=list(collections.Counter(a).items())
b.sort(key=lambda x:int(x[0]))
if len(b)==1:
  print(n)
  sys.exit()
lst=[]
num=b[0][1]
if int(b[1][0])-int(b[0][0])==1:
  num+=b[1][1]
lst.append(num)
for i in range(1,len(b)-1):
  num=b[i][1]
  if int(b[i+1][0])-int(b[i][0])==1:
    num+=b[i+1][1]
  if int(b[i][0])-int(b[i-1][0])==1:
    num+=b[i-1][1]
  lst.append(num)
num=b[len(b)-1][1]
if int(b[len(b)-1][0])-int(b[len(b)-2][0])==1:
  num+=b[len(b)-2][1]
lst.append(num)
print(max(lst))
a = input()
b = input()

s = a * b
l = 2 * (a + b)

print '%d %d' % (s, l) 

### FIXED CODE ###

#reference : http://qiita.com/clarinet758/items/53e31ec10b873975438b
#reference : #1511943 Solution for ITP1_1_C: Rectangle by Signorte
# print "%d %d" % (s ,l) => ERROR

a, b = map(int, raw_input().split())

s = a * b
l = 2 * (a + b)

print "%s %s" % (str(s) ,str(l))
data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
]

# ??\?????????????????????????????§????????????????????????????????????
count = int(input())
for c in range(count):
    c, f, r, v = [int(1) for i in input().split]
    data[b - 1][f - 1][r - 1] += v
    

for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')
    
        print()

    if bi < 3:
        print('#' * 20)

### FIXED CODE ###

data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
]
    
count = int(input())
for c in range(count):
    b,f,r,v = [int(i) for i in input().split()]
    data[b-1] [f-1] [r-1] += v
    
for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')
        print()
    if bi < 3:
        print('#' * 20)
S = input()
Q = int(input())

c2 = 0
query = []
for i in range(Q):
    q = [x for x in input().split()]
    T = int(q[0])
    if T == 1:
        query.append([T])
    else: # T == 2
        F, C = int(q[1]), q[2]
        query.append([T, F, C])
        c2 += 1

while len(query) > c2 + 1:
    print(query)
    T1 = query[i][0]
    if T1 == 1:
        T2 = query[i + 1][0]
        if T2 == 1:
            query = query[:i] + query[i + 2:]
        if T2 == 2:
            F, C = query[i + 1][1], query[i + 1][2]
            if F == 1:
                query[i] = [2, 2, C]
                query[i + 1] = [1]
            else: # F == 2
                query[i] = [2, 1, C]
                query[i + 1] = [1]

M = c2 + 1
for i in range(M):
    T = query[i][0]
    if T == 1:
        L = len(S)
        S = S[L - 1::-1]
    else: # T == 2
        F, C = query[i][1], query[i][2]
        if F == 1:
            S = C + S
        else: # F == 2
            S = S + C

print(S)

### FIXED CODE ###

N, M = [int(x) for x in input().split()]

cond = [None for _ in range(N + 1)]
ok = True
for i in range(M):
    s, c = [int(x) for x in input().split()]
    if cond[s] == None:
        cond[s] = c
    else:
        if cond[s] != c:
            ok = False
            break

if cond[1] == None:
    if N == 1:
        cond[1] = 0
    else:
        cond[1] = 1
else:
    if cond[1] == 0:
        if N != 1:
            ok = False

for i in range(2, N + 1):
    if cond[i] == None:
        cond[i] = 0

if ok == True:
    for i in range(1, N + 1):
        print(cond[i], end='')
    print('')
else:
    print(-1)
#58 A - Kenken Race
N,A,B,C,D = map(int,input().split())
S = input()
A,B,C,D = A-1,B-1,C-1,D-1

# A が B を抜かせるエリア
if B == 1:
    a = S.find('...') + 1
else:
    a = S.find('...',3) + 1

dx = [1,2]

# 先に移動させる方の関数
def dfs_ini(v,seen_ini,X):
    seen_ini[v] = True# v を訪問済みにする
    for i in range(2):
        next_v = v + dx[i]
        # next_v が範囲外 or 壁の場合 or 他方が存在する場合
        if not(-1<next_v<N):
            continue
        if (S[next_v] == '#') or (next_v == X):
            continue
        if seen_ini[next_v] == True:# next_v が探索済みならスルー
            continue
        dfs_ini(next_v,seen_ini,X)

# 後に移動させる方の関数
def dfs_fin(w,seen_fin,Y):
    seen_fin[w] = True# w を訪問済みにする
    for j in range(2):
        next_w = w + dx[j]
        # next_w が範囲外 or 壁の場合 or 他方が存在する場合
        if not(-1<next_w<N):
             continue
        if (S[next_w] == '#')  or (next_w == Y):
             continue
        if seen_fin[next_w] == True:# next_w が探索済みならスルー
             continue
        dfs_fin(next_w,seen_fin,Y)

# A を先に動かした方がいいとき
# B を 先に a まで移動させる
if C>D:
    seen_ini_A = [False]*N
    seen_fin_B = [False]*N
    # B を抜かせるエリアがないとき、B の位置はスタート位置
    if (a < B) or (a > D):
        a = B
    dfs_ini(A,seen_ini_A,a)
    dfs_fin(B,seen_fin_B,C)
    result = 'No'
    if seen_ini_A[C] and seen_fin_B[D]:
        result = 'Yes'

# B を先に動かした方がいいとき
else:
    seen_ini_B = [False]*N
    seen_fin_A = [False]*N
    dfs_ini(B,seen_ini_B,A)
    dfs_fin(A,seen_fin_A,D)
    result = 'No'
    if seen_ini_B[D] and seen_fin_A[C]:
        result = 'Yes'

print(result)

### FIXED CODE ###

#58 A - Kenken Race
import sys
sys.setrecursionlimit(10**7)
N,A,B,C,D = map(int,input().split())
S = input()
A,B,C,D = A-1,B-1,C-1,D-1

# A が B を抜かせるエリア
if B == 1:
    a = S.find('...') + 1
else:
    a = S.find('...',3) + 1

dx = [1,2]

# 先に移動させる方の関数
def dfs_ini(v,seen_ini,X):
    seen_ini[v] = True# v を訪問済みにする
    for i in range(2):
        next_v = v + dx[i]
        # next_v が範囲外 or 壁の場合 or 他方が存在する場合
        if not(-1<next_v<N):
            continue
        if (S[next_v] == '#') or (next_v == X):
            continue
        if seen_ini[next_v] == True:# next_v が探索済みならスルー
            continue
        dfs_ini(next_v,seen_ini,X)

# 後に移動させる方の関数
def dfs_fin(w,seen_fin,Y):
    seen_fin[w] = True# w を訪問済みにする
    for j in range(2):
        next_w = w + dx[j]
        # next_w が範囲外 or 壁の場合 or 他方が存在する場合
        if not(-1<next_w<N):
             continue
        if (S[next_w] == '#')  or (next_w == Y):
             continue
        if seen_fin[next_w] == True:# next_w が探索済みならスルー
             continue
        dfs_fin(next_w,seen_fin,Y)

# A を先に動かした方がいいとき
# B を 先に a まで移動させる
if C>D:
    seen_ini_A = [False]*N
    seen_fin_B = [False]*N
    # B を抜かせるエリアがないとき、B の位置はスタート位置
    if (a < B) or (a > D):
        a = B
    dfs_ini(A,seen_ini_A,a)
    dfs_fin(B,seen_fin_B,C)
    result = 'No'
    if seen_ini_A[C] and seen_fin_B[D]:
        result = 'Yes'

# B を先に動かした方がいいとき
else:
    seen_ini_B = [False]*N
    seen_fin_A = [False]*N
    dfs_ini(B,seen_ini_B,A)
    dfs_fin(A,seen_fin_A,D)
    result = 'No'
    if seen_ini_B[D] and seen_fin_A[C]:
        result = 'Yes'

print(result)
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


# エントリーポイント
def main():
    S, Q = input(str, int)
    front, end, state = "", "", 0
    for _ in range(Q):
        t = int(next(args))
        if t == 1:
            state = (state + 1) % 2
            continue
        F, C = int(next(args)), str(next(args))
        if state == 0:
            if F == 1:
                front = C + front
            else:
                end = end + C
        else:
            if F == 1:
                end = end + C
            else:
                front = C + front
        print(front, end, state)
    ans = front + S + end
    if state == 1:
        ans = end[::-1] + S[::-1] + front[::-1]
    print(ans)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


### FIXED CODE ###

from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


# エントリーポイント
def main():
    S, Q = input(str, int)
    front, end, state = "", "", 0
    for _ in range(Q):
        t = int(next(args))
        if t == 1:
            state = (state + 1) % 2
            continue
        F, C = int(next(args)), str(next(args))
        if state == 0:
            if F == 1:
                front = C + front
            else:
                end = end + C
        else:
            if F == 1:
                end = end + C
            else:
                front = C + front
    ans = front + S + end
    if state == 1:
        ans = end[::-1] + S[::-1] + front[::-1]
    print(ans)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()
from collections import defaultdict
from itertools import permutations

N = int(input())
balls = [tuple(map(int, input().split())) for _ in range(N)]
cnt = defaultdict(int)
for b1, b2 in permutations(balls, 2):
    cnt[(b2[0] - b1[0], b2[1] - b1[1])] += 1
_, n = max(cnt.items(), key=lambda x: x[1])
cost = N - n
print(cost)

### FIXED CODE ###

from collections import defaultdict
from itertools import permutations

N = int(input())
balls = [tuple(map(int, input().split())) for _ in range(N)]
if N == 1: print(1)
else:
    cnt = defaultdict(int)
    for b1, b2 in permutations(balls, 2):
        cnt[(b2[0] - b1[0], b2[1] - b1[1])] += 1
    _, n = max(cnt.items(), key=lambda x: x[1])
    cost = N - n
    print(cost)
n = input()
a= []
for i in range(n):
	city, score = input().split()
	score = int(score)
	a.append((city, score, i+1))
a.sort(key=lambda k : (k[0], -k[1]))
for i in range(n):
	print(a[i][2])

### FIXED CODE ###

n = int(input())
a= []
for i in range(n):
	city, score = input().split()
	score = int(score)
	a.append((city, score, i+1))
a.sort(key=lambda k : (k[0], -k[1]))
for i in range(n):
	print(a[i][2])