Harryxun/stf_run huggingface dataset:
n=int(input())
li=[]
#while True:
for u in range(2):
    try:
        li.append(list(map(int,input().split())))
    except:
        break

#ans=Trueにしておいて、チェックにひっ掛かったらFalseに変える
ans=True

#設定より負の値になっていればNO
for i in range(n):
    if li[i][1]>=0 and li[i][2]>=0:
        continue
    ans=False
    print('No')
    break
        
        
#進める最大値よりも先に存在した場合にNOを出す
if ans==True:
    for j in range(n):
        if li[j][0]<=li[j][1]+li[j][2]:
            continue
        ans=False
        print('No')
        break
#秒数とマス目の和の偶奇を調べる
if ans==True:        
    for k in range(n):
        if li[k][0]%2==(li[k][1]+li[k][2])%2:
            continue
        ans=False
        print('No')
        break
        
if ans==True:
    print('Yes')
        

### FIXED CODE ###

n=int(input())
li=[]
while True:
    try:
        li.append(list(map(int,input().split())))
    except:
        break

#ans=Trueにしておいて、チェックにひっ掛かったらFalseに変える
ans=True

#設定より負の値になっていればNO
for i in range(n):
    if li[i][1]>=0 and li[i][2]>=0:
        continue
    ans=False
    print('No')
    break
        
        
#進める最大値よりも先に存在した場合にNOを出す
if ans==True:
    for j in range(n):
        if li[j][0]>=li[j][1]+li[j][2]:
            continue
        ans=False
        print('No')
        break
#秒数とマス目の和の偶奇を調べる
if ans==True:        
    for k in range(n):
        if li[k][0]%2==(li[k][1]+li[k][2])%2:
            continue
        ans=False
        print('No')
        break
        
if ans==True:
    print('Yes')
import sys
input=sys.stdin.readline
from bisect import bisect_left,insort_left
from numba import njit

@njit
def main():
  d=int(input())
  c=list(map(int,input().split()))
  s=[list(map(int,input().split()))for _ in range(d)]
  t=[int(input())for _ in range(d)]
  m=int(input())
  dq=[list(map(int,input().split()))for _ in range(m)]
  x=[[0]for _ in range(26)]
  ans=0
  for i in range(d):
    v=t[i]-1
    ans+=s[i][v]-c[v]*(i-x[v][-1]+1)*(i-x[v][-1])//2
    x[v].append(i+1)
  for i in range(26):
    ans-=c[i]*(d+1-x[i][-1])*(d-x[i][-1])//2
    x[i].append(d+1)
  for dd,q in dq:
    p=t[dd-1]
    t[dd-1]=q
    ans-=s[dd-1][p-1]
    ans+=s[dd-1][q-1]
    pi=bisect_left(x[p-1],dd)
    qi=bisect_left(x[q-1],dd)
    pl=dd-x[p-1][pi-1]
    pr=x[p-1][pi+1]-dd
    ql=dd-x[q-1][qi-1]
    qr=x[q-1][qi]-dd
    del x[p-1][pi]
    x[q-1].insert(qi,dd)
    ans-=c[p-1]*pl*pr
    ans+=c[q-1]*ql*qr
    print(ans)
if __name__ == "__main__":
  main()

### FIXED CODE ###

d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split()))for _ in range(d)]
t=[int(input())for _ in range(d)]
m=int(input())
dq=[list(map(int,input().split()))for _ in range(m)]
x=[[0]for _ in range(26)]
ans=0
for i in range(d):
  x[t[i]-1].append(i+1)
  ans+=s[i][t[i]-1]
  for j in range(26):ans-=((i+1)-x[j][-1])*c[j]
for i in range(26):
  x[i].append(d+1)
for dd,q in dq:
  p=t[dd-1]
  t[dd-1]=q
  ans-=s[dd-1][p-1]
  ans+=s[dd-1][q-1]
  pi=qi=0
  while x[p-1][pi]!=dd:pi+=1
  while x[q-1][qi]<dd:qi+=1
  pl=dd-x[p-1][pi-1]
  pr=x[p-1][pi+1]-dd
  ql=dd-x[q-1][qi-1]
  qr=x[q-1][qi]-dd
  del x[p-1][pi]
  x[q-1].insert(qi,dd)
  ans-=c[p-1]*pl*pr
  ans+=c[q-1]*ql*qr
  print(ans)
n = int(input())

a = list(int(i) for i in input().split(" "))

prod = 1

for i in a:
  prod *= i
  if prod > (10 ** 18):
  	prod = -1
    break


print(prod)


### FIXED CODE ###

n = int(input())

a = list(int(i) for i in input().split(" "))

prod = 1

if 0 in a:
  prod = 0
else:
  for i in a:
    prod *= i
    if prod > (10 ** 18):
      prod = -1
      break


print(prod)
n, L = list(map(int, input().split()))

"""
L + i - 1の対応する値の配列を作成する 
"""
apple_taste = []
taste_total = 0
for i in range(1, n + 1):
    apple_taste.append(L + i - 1)
    taste_total += L + i - 1


"""
要素数が少ないので愚直に一つずつ除外していって差がより小さい箇所を探す
"""

abs_taste_total = abs(sum(apple_taste))
ans = 10 ** 9 # これを差の絶対値が少ないときに入れ替えるようにする

for i in apple_taste:
    current_total = taste_total - i # iを食べたときの合計値
    abs_current_total = abs(abs(taste_total) - abs(i)) # 現在の値の絶対値。マイナス同士で引くと右辺が正の数として扱われるので絶対値にする

    current_abs = abs(abs(abs_taste_total) - abs(current_total))
    if current_abs < diff:
        diff = current_abs
        ans = current_total

print(ans)


### FIXED CODE ###

# B - Bite Eating
# https://atcoder.jp/contests/abc131/tasks/abc131_b
"""
1~Nの数字がある
数列iの対応する値はL+i-1である

N = [1,2,3,4,5]
l = 1
対応する値=[2,3,4,5,6]

a = 対応する値の総和の絶対値を取得する
b = 1つだけ除外し、残った対応する値の総和の絶対値を取得する
aとbの差をなるべく小さくするには？
対応する値は負になることもある
"""

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

"""
L + i - 1の対応する値の配列を作成する 
"""
apple_taste = []
taste_total = 0
for i in range(1, n + 1):
    apple_taste.append(L + i - 1)
    taste_total += L + i - 1


"""
要素数が少ないので愚直に一つずつ除外していって差がより小さい箇所を探す
"""

abs_taste_total = abs(sum(apple_taste))
ans = 10 ** 9 # これを差の絶対値が少ないときに入れ替えるようにする
diff = 10 ** 9 # この子は差の絶対値を保持しておく

for i in apple_taste:
    current_total = taste_total - i # iを食べたときの合計値
    abs_current_total = abs(abs(taste_total) - abs(i)) # 現在の値の絶対値。マイナス同士で引くと右辺が正の数として扱われるので絶対値にする

    current_abs = abs(abs(abs_taste_total) - abs(current_total))
    if current_abs < diff:
        diff = current_abs
        ans = current_total

print(ans)
n, x, t = int(input())
print((n//x+1)*t)

### FIXED CODE ###

n, x, t = map(int, input().split())
if n % x == 0:
  print(int(n/x*t))
else:
  print(int((n//x+1)*t))
a = map(int, input().split())
d = max(a)
a.remove(d)
ans(d*10+sum(a))



### FIXED CODE ###

a = list(map(int, input().split()))
d = max(a)
a.remove(d)
print(d*10+sum(a))
S=list(input())
K=int(input())
SS=S*2
F=S[1]

if len(S)==1:
	P=int(K//2)
elif S==[F]*len(S):
	P=int((len(S))*K//2)
else:
	for G in range(1,len(S)):
		if S[G-1]==S[G]:
			S[G]="O"
		else:
			continue
	A=S.count("O")
	for J in range(1,len(SS)):
		if SS[J-1]==SS[J]:
			SS[J]="O"
		else:
			continue
	B=SS.count("O")
	P=A+(B-A)*(K-1)
print(P)

### FIXED CODE ###

S=list(input())
K=int(input())
SS=S*2
F=S[0]
if len(S)==1:
	P=int(K//2)
elif S==[F]*len(S):
	P=int((len(S))*K//2)
else:
	for G in range(1,len(S)):
		if S[G-1]==S[G]:
			S[G]="O"
		else:
			continue
	A=S.count("O")
	for J in range(1,len(SS)):
		if SS[J-1]==SS[J]:
			SS[J]="O"
		else:
			continue
	B=SS.count("O")
	P=A+(B-A)*(K-1)
print(P)
import math
N = int (input ())
L = input ().split ()
l = [int(s) for s in L]
list.sort (l, reverse=True)
a = 0
x = 0
m = math.ceil(N/2)
for i in range (m):
    x += int (l[a])
    a += 2
a = 1
y = 0
for i in range (N-m):
    y += int (l[a])
    b += 2
print (x-y)

### FIXED CODE ###

n = int (input ())
a = int (input ())
o = n%500
if a < o:
  print ('No')
else:
  print ('Yes')
import re

s = list(input())
t = list(input())

ls = len(s)
lt = len(t)

if ls < lt:
    print('UNRESTORABLE')
else:
    ans = []
    for i in range(len(s) - len(t) + 1):
        m = re.match(s[i:i + lt], t)
        if m is None:
            continue
        ans.append((s[:i]+t+s[i+lt:]).replace('?', 'a'))
    if not ans:
        print('UNRESTORABLE')
    else:
        print(min(ans))


### FIXED CODE ###

import re

s = input().strip()
t = input().strip()

ls = len(s)
lt = len(t)

if ls < lt:
    print('UNRESTORABLE')
else:
    s = s.replace('?', '.')
    ans = []
    for i in range(len(s) - len(t) + 1):
        m = re.match(s[i:i + lt], t)
        if m is None:
            continue
        ans.append((s[:i]+t+s[i+lt:]).replace('.', 'a'))
    if not ans:
        print('UNRESTORABLE')
    else:
        print(min(ans))
A, B = map(int, input().split())

t = A + B
x = A * B
m = A - B

a_flg = False
b_flg = False

if A > 0:
  a_flg = True
if B > 0:
  b_flg = True
  
if A == 0:
  if B < 0:
    print(m)
if B == 0:
  if A < 0:
    print(t)
if a_flg and b_flg:
  print(x)
elif a_flg == True and b_flg == False:
  print(m)
elif a_flg == False and b_flg == True:
  print(t)
elif a_flg == False and b-flg == False:
  print(x)

### FIXED CODE ###

A, B = map(int, input().split())
 
t = A + B
x = A * B
m = A - B
 
map = {'t': t, 'x': x, 'm': m}

sorted_map = sorted(map.items(), key=lambda x:x[1])

ans = sorted_map[-1]
print(ans[-1])
n = int(input())

ls = list(map(int, input().split()))
list.sort()

rg = range(1, n + 1)

for i in rg:
    print(ls.count(i))
    ls.remove(i)


### FIXED CODE ###

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

ls2 =[0 for x in range(n)]
#0がn個のリストを用意する

for x in ls:
    ls2[x - 1] += 1

for x in range(n):
    print(ls2[x])
a = input()
a = a.split()
b = a[0] - 2*a[1]
if b >= 0:
  print(b)
else:
  print(0)

### FIXED CODE ###

a = list(map(int, input().split()))
b = a[0] - 2*a[1]
if b >= 0:
  print(b)
else:
  print(0)
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
ans=0
for i in range(m)
ans+=l[i]


### FIXED CODE ###

n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
ans=0
for i in range(m):
  ans+=l[i]
print(ans)
import sys
def main():
    # 町の数N, 町iの転送先はindexがAi-1の町
	input = sys.stdin.readline
    N,K = map(int, input.split())
    input = sys.stdin.readline
    A = list(map(int, input.split()))

    # K回移動した時の町番号を出力
    # もし一度出てきた番号が出てきたら記憶している道順リストを使う
    # 最初は道を覚えさせる作業が必要
    now = 0
    history = [0]
    i = 0
    while i<K:
        # まず進む
        now = A[now]-1
        # 道順登録
        if now not in history:
            history.append(now)
            i+=1
        # 以前出てきてる町ならそこから末尾までを自動で進めてiのカウントも進める
        else:
            start = history.index(now)
            r = start + (K-1-i)%(len(history)-start)
            now = history[r]
            break

    print(now+1)

main()


### FIXED CODE ###

def main():
    # 町の数N, 町iの転送先はindexがAi-1の町
    N,K = map(int, input().split())
    A = list(map(int, input().split()))

    # K回移動した時の町番号を出力
    # もし一度出てきた番号が出てきたら記憶している道順リストを使う
    # 最初は道を覚えさせる作業が必要
    now = 0
    history = [0]
    isVisited = [False for i in range(N)]
    i = 0
    while i<K:
        # まず進む
        now = A[now]-1
        # 道順登録
        #if now not in history:
        if isVisited[now] == False:
            history.append(now)
            isVisited[now] = True
            i+=1
        # 以前出てきてる町ならそこから末尾までを自動で進めてiのカウントも進める
        else:
            start = history.index(now)
            r = start + (K-1-i)%(len(history)-start)
            now = history[r]
            break

    print(now+1)

main()
while True:
    n = input()
    if (n == 0):
        break
    d = []
    for i in range(n):
        a = map(int, raw_input().split())
        d.append(a[1:])
    for i in range(31):
        ok = True
        for j in d:
            t = min(j)
            if (i < t):
                ok = False
                break
        if (ok):
            print i
            break
    if (ok):
        continue
    else:
        print -1
    
        


            

### FIXED CODE ###

while True:
    n = input()
    if (n == 0):
        break
    state = []
    schedule = []
    ok = True
    for i in range(n):
        temp = map(int, raw_input().split())
        if temp[0] != 0:
            schedule.append(set(temp[1:]))
        else:
            ok = False
        state.append(set([i]))
    if (ok == False):
        print -1
        continue
    for day in range(1, 31):
        temp = []
        Maps = set()
        for i in range(len(schedule)):
            if day in schedule[i]:
                temp.append(i)
                Maps |= state[i]
        for c in temp:
            state[c] = Maps
        if len(Maps) == n:
            print day
            break
    else:
        print -1
#!python3

from heapq import heappush, heappop, heapify

iim = lambda: map(int, input().rstrip().split())

def resolve():
    H, N = iim()
    AB = [tuple(iim()) for i in range(N)]
    inf = float("inf")

    def memo(f):
        cache = {}
        def wrapper(*a):
            if a in cache:
                return cache[a]
            b = f(*a)
            cache[a] = b

            return b

        return wrapper

    @memo
    def calc(h):
        if h <= 0: return 0

        bi = inf
        for a, b in AB:
            bj = b + calc(h - a)
            if bi > bj:
                bi = bj
        return bi


    print(calc(H))



if __name__ == "__main__":
    resolve()



### FIXED CODE ###

#!python3
import sys
sys.setrecursionlimit(1000000)

from heapq import heappush, heappop, heapify

iim = lambda: map(int, input().rstrip().split())

def resolve():
    H, N = iim()
    AB = [tuple(iim()) for i in range(N)]
    inf = float("inf")
    AB.sort(key=lambda a: (a[0]/a[1], -a[0]), reverse=True)

    def memo(f):
        cache = {}
        def wrapper(*a):
            if a in cache:
                return cache[a]
            b = f(*a)
            cache[a] = b

            return b

        return wrapper

    @memo
    def calc(h):
        if h <= 0: return 0

        bi = inf
        for a, b in AB:
            bj = b + calc(h - a)
            if bi > bj:
                bi = bj
            else:
                break
        return bi

    print(calc(H))



if __name__ == "__main__":
    resolve()
S = int(input())
if S == "ABC"
	print("ARC")
else:
  	print("ABC")

### FIXED CODE ###

S = input()
if S == "ABC":
	print("ARC")
else:
  	print("ABC")
x = int(input)
print("ABC") if x < 1200 else print("ARC")

### FIXED CODE ###

x = int(input())
print("ABC") if x < 1200 else print("ARC")
N = int(input())
s=[]
for i in range(N):
  s.append(input())
num = 0

while(len(s) != 0):
  flag = 0
  a = s[0]
  num += 1
  for i in range(len(s)):
    if(s[0] == s[i]):
      s.remove(a)
    
print(num)

### FIXED CODE ###

import collections
N = int(input())
s=[]
for i in range(N):
  s.append(input())
c = collections.Counter(s)
 
print(len(c))
n, k = map(int, input().split())
a = list(map(int, input().split()))
sorted(a)
print(sum(a[:k])

### FIXED CODE ###

n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
print(sum(a[:k]))
import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
lis1 = [i for i in range(1,N+1)]
lis2 = [i for i in range(1,N+1)]
def number(a, lis):
  total_order = 1
  for i in range(N):
    tmp_order = lis.index(a[i])
    lis.pop(a[i])
    total_order += tmp_order * math.factorial(len(lis))
  return total_order
print(abs(number(P, lis1) - number(Q, lis2)))


### FIXED CODE ###

import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
lis1 = [i for i in range(1,N+1)]
lis2 = [i for i in range(1,N+1)]
def number(a, lis):
  total_order = 1
  for i in range(N):
    tmp_order = lis.index(a[i])
    lis.remove(a[i])
    total_order += tmp_order * math.factorial(len(lis))
  return total_order
print(abs(number(P, lis1) - number(Q, lis2)))
print('?', 10**10)
if input() == 'Y':
    for nod in range(10):
        print('?', 10**nod+1)
        if input() == 'Y':
            break
    ans = 10**nod
else:
    for nod in range(1, 10):
        print('?', 10**nod)
        if input() == 'Y':
            continue
            nod -= 1
        break
    ok = 10**(nod-1)
    ng = 10**nod
    while abs(ok - ng) > 1:
        med = (ok + ng)//2
        print('?', med*10+1)
        if input() == 'N':
            ok = med
        else:
            ng = med
    ans = ok+1
print('!', ans)

### FIXED CODE ###

def inpl(): return [int(i) for i in input().split()]
import numpy as np
ans = float('inf')
N = int(input())
a = np.cumsum(np.array(inpl()))
suma = a[-1]
a = np.delete(a, -1)
for i in a:
    ans = min(ans, abs(suma-2*i))
print(ans)
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
"""
すべてのjで割れない場合、カウントする。
逆に言えば、一つでもiをjで割れるようなjが存在するならば、それはカウントしない。
一番小さい数が2つあればそれはカウントしないが、基本的に一番小さい数はほかのどの数字でも割れない
Aiの制約が10**6であることから、小さい数から数えていって、10**6までの倍数の場所にマークを付ける。
初めて出てくるような数字に関して、カウントを1足してやる。
一番小さい数のコーナーケースに注意
"""
n = int(readline())
lst1 = list(map(int,readline().split()))

lst1.sort()

memo = [0]*(10**6+1)

if lst1[0] == lst1[1]:
    ans = -1
    if lst1[0] == 1:
        print(0)
        exit()
else:
    ans = 0
    if lst1[0] == 1:
        print(1)
        exit()
ans = 0
for i in lst1:
    if memo[i] == 0:
        ans += 1
        j = 1
        while i*j <= 10**6:
            memo[i*j] = 1
            j += 1
    else:
        continue

print(ans)


### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
"""
すべてのjで割れない場合、カウントする。
逆に言えば、一つでもiをjで割れるようなjが存在するならば、それはカウントしない。
一番小さい数が2つあればそれはカウントしないが、基本的に一番小さい数はほかのどの数字でも割れない
Aiの制約が10**6であることから、小さい数から数えていって、10**6までの倍数の場所にマークを付ける。
初めて出てくるような数字に関して、カウントを1足してやる。
一番小さい数のコーナーケースに注意
"""
n = int(readline())
lst1 = list(map(int,readline().split()))

lst1.sort()

memo = [0]*(10**6+1)
if n == 1:
    print(1)
    exit()

ans = 0
for i in range(n):
    if memo[lst1[i]] == 0:
        if i < n-1:
            if lst1[i] != lst1[i+1]:
                ans += 1
        elif i == n-1:
            ans += 1
        j = 1
        while lst1[i]*j <= 10**6:
            memo[lst1[i]*j] = 1
            j += 1

print(ans)
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
def nap(N,goods):
    dp=[-1*float('inf')]*(N+1)
    dp[0]=0
    for i in range(N):
        for w,v in goods:
            if i+w<=N:
                dp[i+w]=max(dp[i+w],dp[i]+v)
    return max([dp[i]+N-i for i in range(N+1)])
goods1=[(a,b) for a,b in zip(A,B) if a<b]
goods2=[(b,a) for a,b in zip(A,B) if a>b]
N=nap(N,[(a,b) for a,b in zip(A,B)])
if len(goods2)==0:
    print(N)
elif len(goods2)==1:
    print(N%goods2[0]+(N//goods2[0])*goods2[1])
elif len(goods2)==3:
    print(nap(N,goods2))
else:
    a,b,c,d=goods2[0][0],goods2[0][1],goods2[1][0],goods2[1][1]
    if b-a<d-c:
        a,b=c,d
    elif b-a==d-c and a>c:
        a,b=c,d
    bord=(N//a)*b+((N%a)//c)*d
    x=N//a
    ans=bord
    for i in range(1,1+x):
        now=(x-i)*b+((N-(x-i)*a)//c)*d
        if now+d<bord:
            break
        else:
            ans=max(ans,now)
    print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
def nap(N,goods):
    dp=[-1*float('inf')]*(N+1)
    dp[0]=0
    for i in range(N):
        for w,v in goods:
            if i+w<=N:
                dp[i+w]=max(dp[i+w],dp[i]+v)
    return max([dp[i]+N-i for i in range(N+1)])
goods1=[(a,b) for a,b in zip(A,B) if a<b]
goods2=[(b,a) for a,b in zip(A,B) if a>b]
if len(goods1)>0:
    N=nap(N,[(a,b) for a,b in zip(A,B)])
if len(goods2)==0:
    print(N)
elif len(goods2)==1:
    print(N%goods2[0][0]+(N//goods2[0][0])*goods2[0][1])
elif len(goods2)==3:
    print(nap(N,goods2))
else:
    a,b,c,d=goods2[0][0],goods2[0][1],goods2[1][0],goods2[1][1]
    if (b-a)/a<(d-c)/c:
        a,b,c,d=c,d,a,b
    elif (b-a)/a==(d-c)/c and a>c:
        a,b,c,d=c,d,a,b
    bord=(N//a)*b+((N%a)//c)*d+(N%a)%c
    x=N//a
    ans=bord
    for i in range(1,1+x):
        now=(x-i)*b+((N-(x-i)*a)//c)*d+(N-(x-i)*a)%c
        if now+d<ans:
            break
        else:
            ans=max(ans,now)
    print(ans)
a=input()
b=input()
l=[1,2,3]
l.remove(a)
l.remove(b)
print(l)

### FIXED CODE ###

l=[1,2,3]
a=int(input())
l.remove(a)
b=int(input())
l.remove(b)
print(l[0])
a = list(map(int,input().split()))
 
A = a[0]
B = a[1]
C = a[2]
D = a[3]
 
while B>0 and D>0:
  D = D - A
  if D <= 0:
    print("No")
    break
  B = B - D
  if B <= 0:
    print("Yes")
    break


### FIXED CODE ###

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

if a[1] >= a[0] :
  print("unsafe")
else: 
  print("safe")
N, A = map(int, input().split())
print(N**2-A)


### FIXED CODE ###

N = int(input())
A = int(input())
print(N ** 2 - A)
def main():

    input = sys.stdin.readline

    n, m = map(int, input().split())
    query = []
    result =  [[] for i in range(n)]
    for _ in range(m):
        p, y = map(int, input().split())
        query.append((p, y))
        result[p-1].append(y)

    result = [sorted(i) for i in result]
 
    for city in query:
        rank = result[city[0]-1].index(city[1])+1
        resultStr = "{}{}".format(str(city[0]).zfill(6), str(rank).zfill(6))
        print(resultStr)

main()

### FIXED CODE ###

def main():
    from sys import stdin
    from bisect import bisect_left

    readline = stdin.readline
    n, m = map(int, readline().split())
    data = [list(map(int, readline().split())) for _ in range(m)]
    t = [[] for _ in range(n)]

    for p, y in data:
        t[p - 1].append(y)

    for i in range(n):
        t[i].sort()

    for p, y in data:
        nth = bisect_left(t[p - 1], y) + 1
        print("%06d%06d" % (p, nth))

main()
n = int(input())
a = list()
f = 0
for i in range(n):
  a[i] = int(input())
k = int(input())
for i in range(n):
  for j in range(n):
    if i == j:
      continue
    if abs(a[i] - a[j]) > k:
      f = 1
if f == 0:
  print("Yay!")
else:
  print(":(")

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e - a > k:
  print(":(")
else:
  print("Yay!")
S = list(input())

for c in range(1,len(S)+1):
    if c%2==1: 
        if S[c] == 'L':
            print('No')
            break
    else:
        if S[c] == 'R':
            print('No')
            break
else:
    print('Yes')


### FIXED CODE ###

S = list(input())

for c in range(1,len(S)+1):
    if c%2==1: 
        if S[c-1] == 'L':
            print('No')
            break
    else:
        if S[c-1] == 'R':
            print('No')
            break
else:
    print('Yes')
K,X = map(input().split())
if K*500 > X-1:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

K,X = map(int,input().split())
if K*500 > X-1:
  print('Yes')
else:
  print('No')
L = sort(list(map(int, input().split())))
 
if L[0] == 5 and L[1] == 5 and L[2] == 7:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

L = sorted(list(map(int, input().split())))
 
if L[0] == 5 and L[1] == 5 and L[2] == 7:
  print('YES')
else:
  print('NO')
N = int(input())
ans = 1
for i in range(1, N+1):
	ans = (ans * i) % 1000000007
print ans

### FIXED CODE ###

N = int(input())
ans = 1
for i in range(1, N+1):
	ans = (ans * i) % 1000000007
print(ans)
S = input()

# ACGT 

num = 0
result = []

for c in S:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    num += 1
  else:
    result.append(num)
    num = 0
    
print(max(result))

### FIXED CODE ###

S = input()

# ACGT 

num = 0
result = [0]

    
for c in S:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    num += 1
  else:
    result.append(num)
    num = 0
result.append(num)
    
#print(result)
print(max(result))
N,A=map(int,input().strip().split())
if A >= (N%500):
  print('Yes')
else:
  print('no')


### FIXED CODE ###

N=int(input())
A=int(input())
if A >= (N%500):
  print('Yes')
else:
  print('No')
s = input()
n = len(s)
up = []
down = []
parity = 0
for i in range(1,n):
  if s[i] != s[i-1]:
    if parity == 0:
      down.append(i)
    else:
      up.append(i)
    parity = 1 - parity
ans = [0 for i in range(n)]
count = 0
top = up[0]
bottom = down[0]
for i in range(n):
  diff = down[0] - i
  if diff % 2 == 1:
    ans[bottom-1] += 1
  else:
    ans[bottom] += 1
  if len(up) > count + 1:
    if i+1 == top:
      count += 1
      top = up[count]
      bottom = down[count]
ANS = list(map(str,ans))
print(' '.join(ANS))

### FIXED CODE ###

s = input()
n = len(s)
up = []
down = []
parity = 0
for i in range(1,n):
  if s[i] != s[i-1]:
    if parity == 0:
      down.append(i)
    else:
      up.append(i)
    parity = 1 - parity
ans = [0 for i in range(n)]
#print(up,down)
for i in range(n):
  if s[i] == 'R':
    diff = down[0] - i
    if diff % 2 == 1:
      ans[down[0]-1] += 1
    else:
      ans[down[0]] += 1
  else:
    diff = i - down[0]
    if diff % 2 == 1:
      ans[down[0]-1] += 1
    else:
      ans[down[0]] += 1
  if up != []:
    if i+1 == up[0]:
      del down[0]
      del up[0]
ANS = list(map(str,ans))
print(' '.join(ANS))