Harryxun/stf_run huggingface dataset:
n,m = map(int,input().split())
print((n-1)*(m-1) if (n-1) > a and (m-1) > 1 else 0)

### FIXED CODE ###

n,m = map(int,input().split())
print((n-1)*(m-1))
N, K = map(int, input().split())

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

H.sort()
H.reverse()


for i in range(K):
  del(H[0])
  
c = 0

for j in range(len(H)):
  c += H[j]

print(c)

### FIXED CODE ###

N, K = map(int, input().split())

if N <= K:
  print(0)
  
else:
  H = list(map(int, input().split()))
  H.sort()
  H.reverse()
  
  c = 0
  for i in range(K, N):
    c += H[i]
  print(c)
N = int(input())
A = list(map(int,input().split()))


maxa = max(A)
import fractions
d = []
for i in range(N):
    if A[i] != maxa:
        d.append(fractions.gcd(maxa , A[i]))
d = list(set(d))
if len(d) == 0:
    print(A[0])
    exit()
d = sorted(d)
print(d[1])

### FIXED CODE ###

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

l = []
r = []
import fractions as fr
l.append(0)
l.append(A[0])
for i in range(1,N-1):
    l.append(fr.gcd(l[i],A[i]))
r.append(0)
r.append(A[-1])
for i in range(1,N-1):
    r.append(fr.gcd(r[i],A[-i-1]))

ans = 0
for i in range(N):
    ans = max(ans, fr.gcd(l[i],r[-i-1]))
print(ans)
# ABC070c
from fractions import gcd
from functools import reduce
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())


def lcm_base(a, b):
    return a * b // fractions.gcd(a, b)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


t = [int(input()) for _ in range(n)]
print(lcm(*t))


### FIXED CODE ###

# ABC070c
from fractions import gcd
from functools import reduce
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())


def lcm_base(a, b):
    return a * b // gcd(a, b)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def gcds(*numbers):
    return reduce(gcd, numbers)


t = [int(input()) for _ in range(n)]
print(lcm(*t))
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
a=sorted(l)
for j in range(k):
  s+=a[-(j+1):]
print(s)

### FIXED CODE ###

n, k = list(map(int, input().split()))
l=[int(x) for x in input().split()]
l.sort()
l.reverse()
print(sum(l[0:k]))
N, K = [int(i) for i in input().split()]
H = list(map(int, input().split()))

# 昇順にソート
H.sort()

for i in  range(K):
    H.pop()

if len(H) > 0:
    print(sum(H))
else:
    print("0")

### FIXED CODE ###

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

# 昇順にソート
H.sort()

if K >= len(H):
    print("0")
else:
    for i in  range(K):
        H.pop()
    print(sum(H))
if A <= 10 and if B <= 10 :
  print(A*B)
else :
  print(-1)

### FIXED CODE ###

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

if A < 10 and B < 10 :
    print(A*B)
else :
    print(-1)
rom collections import Counter
N = int(input())
S = [input() for _ in range(N)]
CS = Counter(S)
v = 0
ans = []
for i  in CS.values():
  v = max(v,i)
for i,j in CS.items():
  if v == j:
    ans.append(i)
ans.sort
print(ans[i] for i in range(len(ans)))

### FIXED CODE ###

from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
CS = Counter(S)
v = 0
ans = []
for i  in CS.values():
  v = max(v,i)
for j,k in CS.items():
  if v == k:
    ans.append(j)
ans.sort()
print(*ans,sep="\n")
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
#elif x<0 and x+y>0: OKOK
#    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>1])
elif x<0 and x+y<0:
    #print((y//abs(x+y))*2+[0,1][y%abs(x+y)>1])
    print((y//abs(x+y))*2)
else:
    print(hhh)


### FIXED CODE ###

T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
 
P = (A1 - B1) * T1
Q = (A2 - B2) * T2
if P > 0:
	P *= -1
	Q *= -1
 
if P + Q < 0:
	print(0)
elif P + Q == 0:
	print("infinity")
else:
	S = (-P) // (P + Q)
	T = (-P) % (P + Q)
	if T != 0:
		print(S * 2 + 1)
	else:
		print(S * 2)
N,W=map(int,input().split())
w=[]
v=[]
for i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)
dp=[[10**22]*(N*(10**3)+1) for i in range(N+1)]
dp[0][0]=0
for i in range(1,N+1):
    for j in range(N*(10**3)+1):
        if j>=v[i]:
            dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
for i in range(N*(10**3),-1,-1):
    if dp[N][i]<=W:
        print(i)
        break


### FIXED CODE ###

N,W=map(int,input().split())
taple=[]
for i in range(N):
    w,v=map(int,input().split())
    taple.append((w,v))
dp=[[10**22]*(N*(10**3)+1) for i in range(N+1)]
dp[0][0]=0
for i in range(1,N+1):
    w,v=taple[i-1]
    for j in range(N*(10**3)+1):
        if j>=v:
            dp[i][j]=min(dp[i-1][j-v]+w,dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
for i in range(N*(10**3),-1,-1):
    if dp[N][i]<=W:
        print(i)
        break
graph = []

def init():
    global graph
    graph = [[False] * 26 + [True] for _ in xrange(27)]
    graph[26][26] = False

def atoi(c):#index
    if c == "#":
        return 26
    return ord(c) - ord("a")

def make_graph(L):
    global graph
    tmp = []
    while "" in L:
        L.remove("")
    for s1, s2 in zip(L, L[1:]):
        if s1[0] == s2[0]:
            tmp += [s1[1:], s2[1:]]
        else:
            if not tmp == []:
                make_graph(tmp)
            tmp = []
            graph[atoi(s2[0])][atoi(s1[0])] = True
    if not tmp == []:
        make_graph(tmp)

def check(start):
    stack = set([start])
    visited = [False] * 27
    while len(stack) != 0:
        cur = stack.pop()
        visited[cur] = True
        if graph[cur][start]:
            return False
        for i in xrange(27):
            if graph[cur][i] and not visited[i]:
                stack.add(i)
    return True

while True:
    n = input()
    if n == 0:
        break
    L = [raw_input() + "#" for _ in xrange(n)]
    init()
    make_graph(L)
    for i in xrange(27):
        if not check(i):
            print "no"
            break
    else:
        print "yes"

### FIXED CODE ###

graph = []

def init():
    global graph
    graph = [[False] * 26 + [True] for _ in xrange(27)]
    graph[26][26] = False

def atoi(c):#index
    if c == "#":
        return 26
    return ord(c) - ord("a")

def make_graph(L):
    global graph
    cur = 0
    L = [L[0]] + [L[i] for i in xrange(1, len(L)) if L[i] != L[i-1]] #
    #while "" in L:
    #    L.remove("")
    tmp = []
    for s1, s2 in zip(L, L[1:]):
        if s1[0] == s2[0]:
            tmp += [s1[1:], s2[1:]]
        else:
            if not tmp == []:
                make_graph(tmp)
            tmp = []
            graph[atoi(s2[0])][atoi(s1[0])] = True
    if not tmp == []:
        make_graph(tmp)

def check(start):
    stack = set([start])
    visited = [False] * 27
    while len(stack) != 0:
        cur = stack.pop()
        visited[cur] = True
        if graph[cur][start]:
            return False
        for i in xrange(27):
            if graph[cur][i] and not visited[i]:
                stack.add(i)
    return True

while True:
    n = input()
    if n == 0:
        break
    L = [raw_input() + "#" for _ in xrange(n)]
    init()
    make_graph(L)
    for i in xrange(27):
        if not check(i):
            print "no"
            break
    else:
        print "yes"
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

N, M = map(int, input().split())
a, b, d = [0]*M, [0]*M, [0]*M
for i in range(M):
    a[i], b[i] = map(int, input().split())
    a[i], b[i] = a[i] - 1, b[i] - 1

G = csr_matrix(([1]*M, (a, b)), shape=(N, N))
D = dijkstra(G, directed=False, indices=[0, N-1])
if D[0][N-1] == 2:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

### FIXED CODE ###

fn = lambda: map(int, input().split())
N, M = fn()
a, b = [0]*M, [0]*M
ones, goals = set(), set()
for i in range(M):
    ai, bi = fn()
    if ai == 1 and bi == N:
        print('POSSIBLE')
        exit()
    elif ai == 1:
        ones.add(bi)
    elif bi == N:
        goals.add(ai)

if len(ones.intersection(goals)) == 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')
A, B = list(map(int, input().split())

if A>=13:
            m = B
elif A>=6:
            m =B/2
else:
            m =0
            
print(m)
       
            

### FIXED CODE ###

a, b = list(map(int, input().split()))
 
if  a>=13:
            m = int(b)
elif a>=6:
            m =int(b/2)
else:
            m =0
            
print(m)
from collections import Counter

def calculate_mode(data):
    c = Counter(data)
    # すべての要素とその出現回数を取り出します。
    freq_scores = c.most_common()
    #c.most_common内の最も多い要素[0]の最大出現回数[1]を[0][1]で指定
    max_count = freq_scores[0][1]

    modes = []
    #出現回数と最大出現回数が等しいかを確認します。
    for num in freq_scores:
        if num[1] == max_count:
            modes.append(num[0])
    return(modes)



n = int(input())
v = list(map(int, input().split()))
a = v[0::2]
b = v[1::2]
c = v[0::2]
d = v[1::2]
ans = 0

f = max(calculate_mode(a))
g = max(calculate_mode(b))
print(f,g)
if f == g :
    for i in range(len(a)):
        if f == a[i]:
            a.remove(f)
        if g == b[i]:
            b.remove(g)
    f = calculate_mode(a)
    g = calculate_mode(b)


for i in range(len(a)):
    if f != c[i]:
        ans += 1
    if g != d[i]:
        ans += 1

print(ans)

### FIXED CODE ###

#Miccさんのコードを参考にさせていただきました
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
e = v[1::2] #偶数番号
o = v[0::2] #奇数番号
ans = 0

a = Counter(e) #Counterオブジェクトを作成(dictのサブクラスでキーに要素、値に出現回数をもつ)
b = Counter(o)

c = a.most_common(2) #出現回数が2番目に多い数までのCounterオブジェクト作成
d = b.most_common(2)

if c[0][0] != d[0][0]: #出現回数が１番多いものが違う時
    ans = n -c[0][1] -d[0][1]
else:                  #出現回数が１番多いものが同じ時
    if len(c) == 1:
        if len(d) == 1:
            ans = n//2
        else:
            ans = n -d[0][1]
    elif len(d) == 1 and len(c) != 1:
        ans = n -c[0][1]
    elif c[0][1] > d[0][1]:
        ans = n -c[0][1] -d[1][1]
    else:
        if c[0][1]==d[0][1]:
            ans = min(n-c[0][1]-d[1][1],n-c[1][1]-d[0][1])
        else:
            ans = n -c[1][1] -d[0][1]
    
print(ans)
#!/usr/bin/env/ python3
N = int(input())
S = input()
#A, B, C = input().split()
#A, B, C, X, Y = map(int, input().split())

#N = int(input())
#H, W = map(int, input().split())
#S = [input() for _ in range(H)]
#print(A[0][0])

ans = 0
for tmp_num in range(1000):
    tmp = str(tmp_num).zfill(3)
    digit = 0
    for i in range(N):
        if S[i] == tmp[digit]:
            digit += 1
	        if digit == 3:
                ans += 1
                break
print(ans)


### FIXED CODE ###

#!/usr/bin/env/ python3
N = int(input())
S = input()
#A, B, C = input().split()
#A, B, C, X, Y = map(int, input().split())

#N = int(input())
#H, W = map(int, input().split())
#S = [input() for _ in range(H)]
#print(A[0][0])

ans = 0
for tmp_num in range(1000):
    tmp = str(tmp_num).zfill(3)
    digit = 0
    for i in range(N):
        if S[i] == tmp[digit]:
            digit += 1
            if digit == 3:
                ans += 1
                break
print(ans)
S = input()
K = int(input())
if (S.count('1') == len(S)):
  print('1')
else:
  p = 0
  if (len(S) == 1):
    print(S[0])
    exit()
  else:  
    while (S[p] == S[p+1] == '1'):
      p += 1
if (p+1 >= K):
  print('1')
else:
  if (p == 0):
    if (S[0] == '1'):
      print(S[1])
    else:
      print(S[0])
  else:
    print(S[p+1])

### FIXED CODE ###

S = input()
K = int(input())
for i in range(K):
  if (int(S[i]) != 1):
    print(S[i])
    exit()
print(1)
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = rl()
a=rl()
a.sort()
b=[0]*2*10**5
ans=[]
for i in a:
    f=True
    if i==2 or i==3:
        ans.append(i)
        b[i]=1
        continue
    if b[i]==1:
        if ans:
            ans.remove(i)
        continue
    for j in range(2,i):
        if i%j==0 and b[j]==1:
            f=False
            break
    if f:
        b[i]=1
        ans.append(i)

print(len(ans))

### FIXED CODE ###

import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = rl()
a=rl()
a.sort()
b=[0]*2*10**6
for i in a:
    if b[i]==0:
        b[i]=-1
        for j in range(2,10**6):
            if i*j>10**6:
                break
            b[i*j]+=1
        continue
    
    if b[i]==-1:
        b[i]=1
cnt = 0
for i in a:
    if b[i]==-1:
        cnt+=1
print(cnt)
N=int(input())
A=list(map(int,input().split()))
MOD=10**9+7
c=0
for i in range(len(A)):
  c+=A[i]*(pow(sum(A)-A[i],-1,MOD)
print(c//2%MOD)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
c=0
for i in range(N-1):
  j=i+1
  if A[j]<A[j-1]:
    gap=A[j-1]-A[j]
    c+=gap
    A[j]+=gap
    
print(c)
import fraction
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
n = int(input())
l = list(map(int, input().split()))
print(gcd_list(l))


### FIXED CODE ###

import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
n = int(input())
l = list(map(int, input().split()))
print(gcd_list(l))
(x, y, a, b, c), p, q, r = [map(int, o.split()) for o in open(0)]
print(sum(sorted(sorted(p)[-x:] + sorted(q)[-y:] + r)[-x-y:]))

### FIXED CODE ###

(x, y, a, b, c), p, q, r = [map(int, o.split()) for o in open(0)]
print(sum(sorted(sorted(p)[-x:] + sorted(q)[-y:] + list(r))[-x-y:]))
# coding: utf-8
# Your code here!

N = int(input())
RGB= list(input())

count = 0
sub = 0

def index_Multi(List):
    r_list = []
    g_list = []
    b_list = []
    for val in range(0,len(List)):
        if "R" == List[val]:
            r_list.append(val)
        elif "G" == List[val]:
            g_list.append(val)
        elif "B" == List[val]:
            b_list.append(val)
    return r_list, g_list, b_list
    
r_list, g_list ,b_list = index_Multi(RGB)

for index, a in enumerate(RGB):
    if a == "R":
        del g_list[0:len([i for i in g_list if i < index])]
        del b_list[0:len([i for i in b_list if i < index])]
        for g in g_list:
            for b in b_list:
                if g-index == b-g or b-index == g-b:
                    sub +=1
        count = count + len(g_list)*len(b_list)
                    
    elif a == "G":
        del b_list[0:len([i for i in b_list if i < index])]
        del r_list[0:len([i for i in r_list if i < index])]
        for b in b_list:
            for r in r_list:
                if b-index == r-b or r-index == b-r:
                    sub +=1
        count = count + len(b_list)*len(r_list)
                
    elif a == "B":
        del r_list[0:len([i for i in r_list if i < index])]
        del g_list[0:len([i for i in g_list if i < index])]
        for r in r_list:
            for g in g_list:
                if r-index == g-r or g-index == r-g:
                    sub +=1
        count = count + len(g_list)*len(r_list) 
        
print(count-sub)


### FIXED CODE ###

import sys
 
X = input()
test = list(X)
for num in test:
  tmp = int(num)
  if tmp == 7:
    print("Yes")
    sys.exit()
print("No")
import sys

W = sys.stdin.readline().strip()
num = 0

while True:
    T = sys.stdin.readline().strip()
    if T == 'END_OF_TEXT'
        break
    T_line = T.split()
    for i in T_line:
        if W == i:
            num += 1

print(num,end='')


### FIXED CODE ###

import sys

W = sys.stdin.readline().strip()
num = 0

while True:
    T = sys.stdin.readline().strip()
    if T == 'END_OF_TEXT':
        break
    t = T.lower()
    T_line = t.split()
    for i in T_line:
        if W == i:
            num += 1

print(num)
s = input()
l = ["dream","dreamer","erase","eraser"]

while len(s) > 0:
    for i in range(len(l)):
        if l[i] in s:
            s = s.replase(l[i],"")
        else:
            break
            
if len(s) == 0:
    print("YES")
else:
    print("NO")


### FIXED CODE ###


S = input()
S = S[::-1]

l = ['maerd','remaerd','esare','resare']
i = 0
while i < len(S):
    for w in l:
        if w == S[i:i+len(w)]:
            i += len(w)
            break
    else:
        print('NO')
        exit()
print('YES')
S=input()
Q=int(input())
qls=[list(map(str,input().split())) for _ in range(Q)]
res=['']*(2*Q)
res[Q]=S
ins = [Q+1, Q-1]
flg=0 #0:right, 1:left
for q in qls:
    if q[0]=='1':
        flg = (flg+1)%2
    else:
        x = (flg+int(q[1]))%2
        idx = ins[x]
        res[idx] = q[2]
        if x==0:
            ins[x]+=1
        else:
            ins[x]-=1
if flg==0:
    print(''.join(res))
else:
    print(''.join(res[::-1]))


### FIXED CODE ###


S=input()
Q=int(input())
qls=[list(map(str,input().split())) for _ in range(Q)]
N=len(S)
res=['']*(2*Q+N)
res[Q:Q+N]=S
ins = [Q+N, Q-1]
flg=0 #0:right, 1:left
for q in qls:
    if q[0]=='1':
        flg = (flg+1)%2
    else:
        x = (flg+int(q[1]))%2
        idx = ins[x]
        res[idx] = q[2]
        if x==0:
            ins[x]+=1
        else:
            ins[x]-=1
if flg==0:
    print(''.join(res))
else:
    print(''.join(res[::-1]))
A = int(input())
B = int(input())
C = int(input())
print(C, A, B) 

### FIXED CODE ###

A,B,C= map(int,input().split())
print(C,A,B)
a,b=int(input().split())
print(a*b)

### FIXED CODE ###

a,b=map(int,(input()).split())
print(a*b)
print(c*T+T)


### FIXED CODE ###

N, X, T= map(int, input().split())
c=int(N/X)
if N%X == 0:
    print(c*T)
else:
    print(c*T+T)
N,K = map(int,input().split())
if N%K==0:
    print(0)
else:
    print(

### FIXED CODE ###

N,K = map(int,input().split())
if N%K==0:
    print(0)
else:
    print(1)
a,b=map(int,input().split())
if a>10:
    print('b')
else:
    print(b-(100＊(10-b))

### FIXED CODE ###

a,b=map(int,input().split())
if a>9:
  print(b)
else:
  print(b+(100*(10-a)))
n, T= map(int, input().split())
m = 1001
for i in range(n):
  c, t = map(int, input().split())
  if t < T:
    m = min(c, m)
if m == 1001:
  print("TLE")
else:
  print(m)

### FIXED CODE ###

n = int(input())
if n ==1 :
  print("Hello World")
else :
  a = [int(input()) for i in range(n)]
  print(a[0] + a[1])
import sys

def solveA(S):
    N = len(S)
    count = 0
    for i in range(N-1):
        if S[i] == S[i+1]:
            S[i+1] = "_"
            count += 1
    return count

def solve(S, K):
    S0 = S[:]
    N = len(S)
    if N == 1:
        return (K-(K%2))//2
    if K < 10:
        return solveA(S*K)
    actual=(solveA(S*K))
    S1 = S0*1
    S2 = S0*2
    c1 = solveA(S1)
    c2 = solveA(S2)
    if c1 * 2 == c2:
        return c1 * K
    if S2[0] != S2[-1]:
        return c2 * (K//2) + (K%2) * c1
    else:
        a =  c2 * (K//2) + (K%2)*c1 + (K//2)-(1-K%2)
            #if a != solveA(S0*K):
            #print(c1, c2, S2[0]!=S2[-1])
            #print("c2 * (K//2) +(K%2)*c1=", c2 * (K//2)+(K%2)*c1)
        return a


def main():
    S = list(input().rstrip()) # len(S) <= 100
    K = int(input())    # K <= 10**9

    print(solve(S, K))
def test():
    import random

    for i in range(2000):
        n = random.randint(1,100)
        S = random.choices("aaaaaabcedbdddddklkjlkjdsfaak", k=n)
        S0 = S[:]
        K = random.randint(2, 30)
        SK = S*K
        a, a0 = solve(S, K), solveA(SK)
        if a != a0:
            print("".join(S0))
            print(K)
            print("actual=",a, ",expected=",a0)
            print("BAD\n")
            return
#test()
main()


### FIXED CODE ###

import sys

def solveA(S):
    N = len(S)
    count = 0
    for i in range(N-1):
        if S[i] == S[i+1]:
            S[i+1] = "_"
            count += 1
    return count

def solve(S, K):
    S0 = S[:]
    N = len(S)
    if N == 1:
        return (K-(K%2))//2
    if K < 10:
        return solveA(S*K)
    #actual=(solveA(S*K))
    S1 = S0*1
    S2 = S0*2
    c1 = solveA(S1)
    c2 = solveA(S2)
    if c1 * 2 == c2:
        return c1 * K
    if S2[0] != S2[-1]:
        return c2 * (K//2) + (K%2) * c1
    else:
        a =  c2 * (K//2) + (K%2)*c1 + (K//2)-(1-K%2)
            #if a != solveA(S0*K):
            #print(c1, c2, S2[0]!=S2[-1])
            #print("c2 * (K//2) +(K%2)*c1=", c2 * (K//2)+(K%2)*c1)
        return a


def main():
    S = list(input().rstrip()) # len(S) <= 100
    K = int(input())    # K <= 10**9

    print(solve(S, K))
def test():
    import random

    for i in range(2000):
        n = random.randint(1,100)
        S = random.choices("aaaaaabcedbdddddklkjlkjdsfaak", k=n)
        S0 = S[:]
        K = random.randint(2, 30)
        SK = S*K
        a, a0 = solve(S, K), solveA(SK)
        if a != a0:
            print("".join(S0))
            print(K)
            print("actual=",a, ",expected=",a0)
            print("BAD\n")
            return
#test()
main()
n, m = map(int, input().split())
AC = [0] * n
WA = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC': and a[p] == 0:
        AC[p] += 1
        w += W[p]
    elif s == 'WA' and a[p] == 0:
        WA[p] += 1

print(sum(a), w)


### FIXED CODE ###

n, m = map(int, input().split())
AC = [0] * n
WA = [0] * n
w = 0

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and AC[p] == 0:
        AC[p] += 1
        w += WA[p]
    elif s == 'WA' and AC[p] == 0:
        WA[p] += 1

print(sum(AC), w)
n,m,x=map(int,input().split())
C=list()
A=list()
for i in range(n):
    c=list(map(int,input().split()))
    C.append(c[0])
    A.append(c[1:m+1])
L=[0]*m
for i in range(n):
    for j in range(m):
        L[j]+=A[i][j]
if min(L)<x:
    print(-1)
else:
    import itertools
    v=list(itertools.permutations([i for i in range(n)]))
    l=[0]*len(v)
    for i in range(len(v)):
        z=v[i]
        r=[0]*m
        for j in range(n):
            l[i]+=C[z[j]]
            for k in range(m):
                r[k]+=A[z[j]][k]
            if min(r)>=x:
                break
    print(min(l))
    

### FIXED CODE ###

s=input()
t=input()
if t[0:len(t)-1]==s:
    print('Yes')
else:
    print('No')
a, b, c = map(int, input().split())

if a+b+c > 21:
    print('bust')
elif a+b+c <= 21:
    pring('win')

### FIXED CODE ###

a, b, c = map(int, input().split())

if a+b+c > 21:
    print('bust')
elif a+b+c <= 21:
    print('win')
N=int(input())
x=N%10
if x==3:
  print("bon")
elif x==0 or x==1 or X==6 or x==8:
  print("pon")
else:
  print("hon")

### FIXED CODE ###


N=int(input(""))
x=N%10
if x==3:
  print("bon")
elif x==0 or x==1 or x==6 or x==8:
  print("pon")
else:
  print("hon")
import numpy as np
N, M = map(int,input().split())
Ps = [[] for _ in range(N)]
for i in range(M):
    j, Y = map(int,input().split())
    Ps[j-1].append([i,Y])

rets = [""]*M
for i,P in enumerate(Ps):
    inds = np.array(P)[:,0]
    years = np.array(P)[:,1]
    sorts = np.argsort(years)
    for (j,y,s) in zip(inds,years,sorts):
        rets[j] = "{:06d}{:06d}".format(i+1,s+1)
for ret in rets:
    print(ret)

### FIXED CODE ###

from collections import defaultdict
from bisect import bisect_left
N, M = map(int, input().split())
A = []
B = defaultdict(list)
 
for i in range(M):
    p, y = map(int, input().split())
    A.append([p, y])
    B[p].append(y)
 
for key in B.keys():
    B[key].sort()

# print(A,B)
# for a in A:
#     print(a[0],a[1],B[a[0]],bisect_left(B[a[0]],a[1]))
for a in A:
    print("%06d%06d" % (a[0], bisect_left(B[a[0]], a[1])+1))