Harryxun/stf_run huggingface dataset:
n, m = map(int, input().readline().split())
py = []
for _ in range(m):
  py.append(list(map(int,input().split())) + [0])

sortPy = sorted(py, key = lambda x : (x[0], x[1]))
 
d = {}
for i, (p, y, n) in enumerate(sortPy):
  if p in d:
    d[p] += 1
  else:
    d[p] = 1
  sortPy[i][2] = d[p]
 
for p, y, n in py:
  print(str(p).zfill(6) + str(n).zfill(6))

### FIXED CODE ###

n, m = map(int, input().split())
py = []
for _ in range(m):
  py.append(list(map(int,input().split())) + [0])

sortPy = sorted(py, key = lambda x : (x[0], x[1]))
 
d = {}
for i, (p, y, n) in enumerate(sortPy):
  if p in d:
    d[p] += 1
  else:
    d[p] = 1
  sortPy[i][2] = d[p]

for p, y, n in py:
  print(str(p).zfill(6) + str(n).zfill(6))
n = int(input())
A = list(map(int, input().split()))
A.sort()
hst = [0] * (max(A) + 1)
for a in A:
    hst[a] += 1

rec = []
squ = []
for a in list(set(A)):
    if hst[a] > 1:
        rec.append(a)
    if hst[a] >= 4:
        squ.append(a)

# print(rec)
# print(squ)

s = 0
if len(squ) != 0:
    s = squ[-1]**2

if len(rec) < 2 and s == 0:
    print(0)
else:
    print(max(s, rec[-1]*rec[-2]))

### FIXED CODE ###

from collections import Counter
n = int(input())
A = list(map(int, input().split()))

C = Counter(A)

rec = []
squ = []

for a in A:
    if 2 <= C[a]:
        rec.append(a)
    if 4 <= C[a]:
        squ.append(a)
rec = list(set(rec))
squ = list(set(squ))
# print(rec)
# print(squ)

s = 0
if len(squ) != 0:
    s = max(squ)**2

if len(rec) < 2:
    print(s)
else:
    rec.sort(reverse=True)
    print(max(s, rec[0]*rec[1]))
a = int(input())
array = list(map(int, input().split())) 
ans = "APPROVED"
nu = 0
for i in range a:
  nu = array[i]
  if nu % 2 == 0:
    if nu % 3 == 0 or nu % 5 == 0:
      pass
    else:
      ans = "DENIED"
print(ans)

### FIXED CODE ###

a = int(input())
array = list(map(int, input().split())) 
ans = "APPROVED"
nu = 0
for i in range (a):
  nu = array[i]
  if nu % 2 == 0:
    if nu % 3 == 0 or nu % 5 == 0:
      pass
    else:
      ans = "DENIED"
print(ans)
import collections
def kaijo(x):
    a=1
    for i in range(1,x+1):
        a*=i
    return a
def perm(x,y):
    ans=1
    for i in range(x,x-y,-1):
        ans*=i
    return ans
def com(x,y):
    return perm(x,min(y,x-y))//kaijo(min(y,x-y))

nn,m=map(int,input().split())
x=primes(int(m**0.5+1))
y=[]
z=m
t=1
while(t**2<=m):
    t+=1
    while(z%t==0):
        y.append(t)
        z//=t
if len(y)==0 and m>1:
    y.append(m)
c=collections.Counter(y).values()
ans=1
mod=10**9+7
for t in c:
    ans*=com(t+nn-1,t)
    ans%=mod
print(ans)

### FIXED CODE ###

import collections
def com(x,y):
    y=min(y,x-y)
    a=1
    for i in range(x,x-y,-1):
        a*=i
    b=1
    for i in range(1,y+1):
        b*=i
    return a//b
n,m=map(int,input().split())
y=[]
i=2
z=m
while(i*i<=m):
    if m%i:
        i+=1
    else:
        m//=i
        y.append(i)
if m>1:
    y.append(m)
c=collections.Counter(y).values()
ans=1
mod=10**9+7
for t in c:
    ans*=com(t+n-1,t)
    ans%=mod
print(ans)
print(sum(list(range(1,int(input())))))

### FIXED CODE ###

N = int(input())
print(N*(N-1)//2)
,b,c,d=map(int,input().split())
print(max(0,min(b,d)-max(a,c)))

### FIXED CODE ###

a,b,c,d=map(int,input().split())
print(max(0,min(b,d)-max(a,c)))
import sys
sys.setrecursionlimit(100000)

def val_add(i,con,val):
    if con[i] :
        for j in con[i]:
            val[j]+=val[i]
            val_add(j,con,val)

def tree(i,con):
    if not con[i]: pass
    else :
        for j in con[i]:
            con[j].remove(i)
            tree(j,con)

def main():
    n,q=map(int,input().split())
    con=[[] for _ in range(n)]
    val=[0]*n
    for _ in range(n-1):
        a,b=map(int,input().split())
        con[a-1].append(b-1)
        con[b-1].append(a-1)

    tree(0,con)

    for _ in range(q):
        p,x=map(int,input().split())
        val[p-1]+=x

    val_add(0,con,val)


    print(" ".join(map(str,val)))

main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

def val_add(i,con,val):
    if con[i] :
        for j in con[i]:
            val[j]+=val[i]
            val_add(j,con,val)

def tree(i,con):
    if not con[i]: pass
    else :
        for j in con[i]:
            con[j].remove(i)
            tree(j,con)

def main():
    n,q=map(int,input().split())
    con=[[] for _ in range(n)]
    val=[0]*n
    for _ in range(n-1):
        a,b=map(int,input().split())
        con[a-1].append(b-1)
        con[b-1].append(a-1)

    tree(0,con)

    for _ in range(q):
        p,x=map(int,input().split())
        val[p-1]+=x

    val_add(0,con,val)


    print(" ".join(map(str,val)))

main()
N = int(input())

ans = 0

diclist = []

for i in range(0,N+1):
  temp = list(input()).sort()
  if temp in diclist:
    ans = ans +1
  else:
    diclist.append(temp_str)

print("{}".format(ans))


### FIXED CODE ###

import collections
from scipy.misc import comb

N = int(input())

diclist = []

i=0
while i < N:
  temp = list(input())
  temp.sort()
  tmp_el = ''.join(temp)
  diclist.append(tmp_el)
  i += 1
  
c = collections.Counter(diclist)
clist = list(c.values()) 
ccomb = [comb(clist[i], 2, exact = True) for i in range(0,len(clist))]

print(sum(ccomb))
# coding: utf-8

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    if sum(A) < sum(B):
        return -1

    diff_sum = 0
    diff_cnt = 0
    diff_list = [0] * N
    for i in range(N):
        diff_list[i] = A[i] - B[i]
        if A[i] < B[i]:
            diff_sum += B[i] - A[i]
            diff_cnt += 1

    diff_list_sorted = sorted(diff_list, reverse=True)

    use_sum = 0
    for i in range(N):
        if use_sum >= diff_sum:
            break
        use_sum += diff_list_sorted[i]
        diff_cnt += 1

    return diff_cnt


if __name__ == "__main__":
    print(main()


### FIXED CODE ###

# coding: utf-8

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    if sum(A) < sum(B):
        return -1

    diff_sum = 0
    diff_cnt = 0
    diff_list = [0] * N
    for i in range(N):
        diff_list[i] = A[i] - B[i]
        if A[i] < B[i]:
            diff_sum += B[i] - A[i]
            diff_cnt += 1

    diff_list_sorted = sorted(diff_list, reverse=True)

    use_sum = 0
    for i in range(N):
        if use_sum >= diff_sum:
            break
        use_sum += diff_list_sorted[i]
        diff_cnt += 1

    return diff_cnt


if __name__ == "__main__":
    print(main())
import numpy as np
room, route_count = map(int,input().split())
route = np.array([list(map(int,input().split())) for _ in range(route_count)])
 
object_nums = [1]
ans = np.array([0]*(room-1))
 
def mem_ans(ans, object_num, next_nums):
    next_nums = next_nums - 2
    ans[next_nums-2] = object_num
    return ans
 
for object_num in object_nums:
    object_rows = route[np.any(route==object_num, axis=1)]
    route = route[~np.any(route==object_num, axis=1)]
    next_nums = object_rows[object_rows!=object_num]
    
    if next_nums is not None:
        ans = mem_ans(ans, object_num, next_nums)
        object_nums.extend(next_nums)
    else:
        break
if 0 in set(ans):
  print('No')
else:
  print('Yes')
  for i in ans:
    print(i)

### FIXED CODE ###

count = int(input()[-1])
if count == 2 or count == 4 or count == 5 or count == 7 or count == 9:
  print('hon')
elif count == 3:
  print('bon')
else:
  print('pon')
S = int(input())
A = list(map(int,input().split()))

def main():
    new_A = sorted(A)

    for i in range(S-1):
        if new_A[i] == new_A[i+1]:
            flag = 1
            break
        else:
            continue
        
    if flag == 0:
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    main()
    

### FIXED CODE ###

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

def main():
    flag = 0
    new_A = sorted(A)

    for i in range(S-1):
        if new_A[i] == new_A[i+1]:
            flag = 1
            break
        else:
            continue

    if flag == 0:
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    main()
n=int(input())
    a=list(map(int,input().split(" ")))
    deta=[]
    error=False
    try:
      for i in range(n):
        if len(deta)==0:
          pass
        elif error:
          break
        elif a[i] in deta:
          error=True
        deta.append(a[i])
    if error:
      print("YES")
    else:
      print("NO")

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split(" ")))
deta = set()
error = False

for i in range(n):
    if n == 0:
        pass
    elif error:
        break
    elif a[i] in deta:
        error = True
        break
    deta.add(a[i])
if error:
    print("NO")
else:
    print("YES")
import fractions
A,B,C,D=map(int,input().split())
X=0
L=0
M=0
N=0
E=C*D//fractions.gcd(C,D)
if B-A>=C:
    if A%C==0 or B%C==0:
        L=(B-A)//C+1
    else:
        L=(B-A)//C
else:
    if A%C==0 or B%C==0:
        L=!
    elif A%C>B%C:
        L=1
    else:
        L=0
if B-A>=D:        
    if A%D==0 or B%D==0:
        M=(B-A)//D+1
    else:
        M=(B-A)//D
else:
    if A%D==0 or B%D==0:
        M=1
    elif A%D>B%D:
        M=1
    else:
        M=0       
if B-A>=E:
    if A%E==0 or B%E==0:
        N=(B-A)//E+1
    else:
        N=(B-A)//E
else:
    if A%E==0 or B%E==0:
        N=!
    elif A%E>B%E :
        N=1
    else :
        N=0
X=B-A+1-L-M+N
print(X)


### FIXED CODE ###

import fractions
A,B,C,D=map(int,input().split())
E=C*D//fractions.gcd(C,D)
X=0
Y=0
X=A-1-(A-1)//C-(A-1)//D+(A-1)//E
Y=B-B//C-B//D+B//E
print(Y-X)
N,D=map(int, input().split)
print((N-1)//(D*2+1)+1)

### FIXED CODE ###

N,D=map(int, input().split())
print((N-1)//(D*2+1)+1)
n,m = list(map(int, input().split()))
x = []
ans = [0]*m
answ = 0
s,c = [], []

def has_duplicates(seq):
    return len(seq) != len(set(seq))

for i in range(m):
  x.append(list(map(int,input().split())))
  
#重複を取り除く
x = list(map(list, set(map(tuple, x))))

for i,j in x:
  s.append(i)
  c.append(j)
  
if m == 0:
  print(-1)
#sに重複があれば－１を出力
elif has_duplicates(s):
  print(-1)
else:
  for i,j in x:
    ans[i-1] = j
    
  if (ans[0] == 0) and (s.count(1) == 0):
    ans[0] = 1
    
  for i in range(len(ans)):
    answ += ans[i]*(10**(m-1-i))

  if ans[0] == 0:
    print(-1)
  else:
    print(answ)

### FIXED CODE ###

n,m = list(map(int, input().split()))
x = []
ans = [0]*n
answ = 0
s,c = [], []

def has_duplicates(seq):
    return len(seq) != len(set(seq))

for i in range(m):
  x.append(list(map(int,input().split())))
  
#重複を取り除く
x = list(map(list, set(map(tuple, x))))

for i,j in x:
  s.append(i)
  c.append(j)

if (n == 1) and (m == 0):
  print(0)
elif m == 0:
  ans[0] = 1
  for i in range(len(ans)):
    answ += ans[i]*(10**(n-1-i))
    
  print(answ)
elif has_duplicates(s):
  print(-1)
elif (n == 1) and (c.count(0) == 1):
  print(0)
else:
  for i,j in x:
    ans[i-1] = j
    
  if (ans[0] == 0) and (s.count(1) == 0):
    ans[0] = 1
    
  for i in range(len(ans)):
    answ += ans[i]*(10**(n-1-i))

  if ans[0] == 0:
    print(-1)
  else:
    print(answ)
list = [int(input()) for i in range(5)]
min = 9
ans = 0
for i in range(5):
  amari = list[i] % 10
  if amari != 0 and amari < min:
    min = amari
    num_min = i
for i in range(5):
  if i != num_min:
    if list[i] % 10 == 0:
      ans += list[i]
    else:
      ans += (list[i] // 10 + 1) * 10
  elif i == num_min:
    ans += list[i]
print(ans)

### FIXED CODE ###

list = [int(input()) for i in range(5)]
ans = 0
amari = []
for i in range(5):
  ans += (list[i] // 10) * 10
  amari.append(list[i] % 10)
amari = sorted(amari)
for i in range(5):
  if amari[i] != 0:
    ans += amari[i]
    ans += (5-(i+1)) * 10
    break
print(ans)
tBeA = 0
tBeNA = 0
tNBeA = 0
for i in range(N):
    flag = False
    if a[i][0] == "B":
        if a[i][-1] == "A":
            tBeA += 1
        else:
            tBeNA += 1
    else:
        if a[i][-1] == "A":
            tNBeA += 1

    for j in range(len(a[i])):
        # print(a[i][j])
        if a[i][j] == "B" and flag:
            cnt += 1
        flag = False

        if a[i][j] == "A":
            flag = True

print(
    cnt + min(tBeNA, tNBeA) if tBeA == 0 else cnt + min(tBeNA, tNBeA) + tBeA if tNBeA + tBeNA > 0 else cnt + min(tBeNA,
                                                                                                                 tNBeA) + tBeA - 1)


### FIXED CODE ###

N = int(input())
a = [str(input()) for i in range(N)]
cnt = 0
tBeA = 0
tBeNA = 0
tNBeA = 0
for i in range(N):
    flag = False
    if a[i][0] == "B":
        if a[i][-1] == "A":
            tBeA += 1
        else:
            tBeNA += 1
    else:
        if a[i][-1] == "A":
            tNBeA += 1

    for j in range(len(a[i])):
        # print(a[i][j])
        if a[i][j] == "B" and flag:
            cnt += 1
        flag = False

        if a[i][j] == "A":
            flag = True

print(
    cnt + min(tBeNA, tNBeA) if tBeA == 0 else cnt + min(tBeNA, tNBeA) + tBeA if tNBeA + tBeNA > 0 else cnt + min(tBeNA,
                                                                                                                 tNBeA) + tBeA - 1)
S=input()
C1=S[0]=='A' and S[-1].islower()
C1=C1 and S[1].islower()
C2=0
C3=0
for i in S[2:len(S)-1]:
  if i=='C':
    C2+=1
  elif i.islower():
  else:
    C3+=1
if C1 and C2==1 and C3==0:
  print('AC')
else:
  print('WA')


### FIXED CODE ###

S=input()
C1=S[0]=='A' and S[-1].islower()
C1=C1 and S[1].islower()
C2=0
C3=0
for i in S[2:len(S)-1]:
  if i=='C':
    C2+=1
  elif i.islower():
    C3=C3
  else:
    C3+=1
if C1 and C2==1 and C3==0:
  print('AC')
else:
  print('WA')
S = input();
day = [SUN,MON,TUE,WED,THU,FRI,SAT];

print(day.index(S)]

### FIXED CODE ###

S = input();
day = ["SUN","MON","TUE","WED","THU","FRI","SAT"];

print(7 - day.index(S))
# coding: utf-8
# Your code here!


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

lst = [i for i in range(k+1)]


ans = 0
ans = s_bool.sum()

print(ans)











### FIXED CODE ###

# coding: utf-8
# Your code here!

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

cnt = 0

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

print(cnt)
#C
#入力
N=int(input())
S=[input() for i in range(N)]

#処理
result={}
for i in S:
    if i in result:
        result[i]+=1
    else:
        result[i]=1

x=max(result.values())
x.sort

for i in result.items():
    if i[1]==x:
        print(i[0])

### FIXED CODE ###

#C
#入力
N=int(input())
S=[input() for i in range(N)]

#処理
result={}
for i in S:
    if i in result:
        result[i]+=1
    else:
        result[i]=1

x=max(result.values())

Z=[]
for i in result.items():
    if i[1]==x:
        Z.append(i[0])
Z.sort()
for i in Z:
    print(i)
n, m = [0] * 2

def format_input(filename = None):
	global n, m
	if filename == None:
		n, m = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(3, 10**5)
		m = rng(1, (n-1) // 2)
		print(n, m)

def get_answer():
	median = n // 2

	for i in range(m)
		print(median-i, median+i+1)


if __name__ == '__main__':
	format_input()

	get_answer()


### FIXED CODE ###



n, m = [0] * 2

def format_input(filename = None):
	global n, m
	if filename == None:
		n, m = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(3, 10**5)
		m = rng(1, (n-1) // 2)
		print(n, m)

def get_answer():
	median = n // 2

	for i in range(m):
		if n % 2 == 0 and i >= n // 4:
			print(median-i, median+i+2)
		else:
			print(median-i, median+i+1)


if __name__ == '__main__':
	format_input()

	get_answer()
a,b=map(int,input().split())
print([[0,b//2][a>5,b][a>12])

### FIXED CODE ###

a,b=map(int,input().split())
print([[0,b//2][a>5],b][a>12])
import numpy as np
n=int(input())
s=list(map(int,input().split()))
x=np.argsort(s)
print(*x+1)

### FIXED CODE ###

import numpy as np
n=int(input())
s=list(map(int,input().split()))
x=np.argsort(s)
print(*x+1)
N = input()
print(N ** 3)

### FIXED CODE ###

N = int(input())
print(N ** 3)
N= int(input())
num = list()

for i in range(0,N-1):
  d = int(input())
  num[d] = 1
  
res = 0
for i in range (0,N-1):
  res += num[i]
  
print(res)
  



### FIXED CODE ###

N = int(input())
num = list()

for i in range (N):
  d = int (input())
  num.append(d)
  
print(len(set(num)))
print(sum[i for i in range(1, int(input())+1)]

### FIXED CODE ###

print(sum([i for i in range(1, int(input())+1)]))
N = int(input())
S = list(input())
if N // 2 == 1:
    print('No')
elif:
    S[0:N//2] == S[N//2:-1]:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

N = int(input())
S = list(input())
if N % 2 == 1:
    print('No')
elif S[:N//2] == S[N//2:]:
    print('Yes')
else:
    print('No')
n,w=map(int,input().split())

weight=[]
value=[]

for i in range(n):
    a,b=map(int,input().split())
    weight+=[a]
    value+=[b]

dp=[[0]*(w+1) for i in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j<w[i]:
            dp[i+1][j]=dp[i][j]
        else:
            dp[i+1][j]=max(dp[i][j],dp[i][j-weight[i]]+value[i])

print(dp[n][w])

### FIXED CODE ###

n,w=map(int,input().split())
wi=[]
vi=[]

for i in range(n):
  a,b=map(int,input().split())
  wi+=[a]
  vi+=[b]
  
dp=[[0]*(w+1) for i in range(n+1)]

for i in range(n):
  for j in range(w+1):
    if j<wi[i]:
      dp[i+1][j]=dp[i][j]
      
    else:
      dp[i+1][j]=max(dp[i][j],dp[i][j-wi[i]]+vi[i])
      
print(dp[n][w])
import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())
    xy = [list(map(int,input().split())) for i in range(N)]

    xy = np.array(xy,dtype='int32')
    # print(xy)

    diffs = np.expand_dims(xy,axis=1) - np.expand_dims(xy,axis=0)
    md = np.sum(np.abs(diffs),axis=-1)
    res = md.max()

    # print(diffs)
    # print(md)

    print(res)



main()


### FIXED CODE ###

import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())
    xy = [list(map(int,input().split())) for i in range(N)]

    z_max = 0
    z_min = 2 * 10 **9

    w_max = - 10 ** 9
    w_min = 10 ** 9

    for i in range(N):
        z = xy[i][0] + xy[i][1]
        w = xy[i][0] - xy[i][1]
        z_max = max(z_max,z)
        z_min = min(z_min,z)
        w_max = max(w_max,w)
        w_min = min(w_min,w)

    res = max(z_max-z_min,w_max-w_min)

    print(res)



main()
import sys
input = sys.stdin.readline
 
H, W, M = map(int, input().split())
Hsum = [0] * H
Wsum = [0] * W
hw = set()
for m in range(M):
  h, w = map(lambda x: int(x) - 1, input().split())
  Hsum[h] += 1
  Wsum[w] += 1
  hw.add((h, w))

mh = max(Hsum)
mw = max(Wsum)
hidx = [i for i, _ in enumerate(Hsum) if _ == mh]
widx = [i for i, _ in enumerate(Wsum) if _ == mw]

if len(hidx) * len(widx) > M:
  print(mh + mw)
else:
  fi_flg = False
  for h in hidx:
    for w in widx:
      if (h, w) not in hw:
        print(mh + mw)
        fi_flg = True
        break
    if fi_flg:
      break
if fi_flg is False:
  print(mh + mw - 1)

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
H, W, M = map(int, input().split())
Hsum = [0] * H
Wsum = [0] * W
hw = set()
for m in range(M):
  h, w = map(lambda x: int(x) - 1, input().split())
  Hsum[h] += 1
  Wsum[w] += 1
  hw.add((h, w))

mh = max(Hsum)
mw = max(Wsum)
hidx = [i for i, _ in enumerate(Hsum) if _ == mh]
widx = [i for i, _ in enumerate(Wsum) if _ == mw]
 
if len(hidx) * len(widx) > M:
  print(mh + mw)
else:
  fi_flg = False
  for h in hidx:
    for w in widx:
      if (h, w) not in hw:
        print(mh + mw)
        fi_flg = True
        break
    if fi_flg:
      break
  if fi_flg is False:
    print(mh + mw - 1)
class Dice():
        def __init__(self,data):
                self.number = data

        def rota_S(self):
                self.number[0],self.number[1],self.number[5],self.number[4] = self.number[1],self.$
        def rota_E(self):
                self.number[0],self.number[2],self.number[5],self.number[3] = self.number[2],self.$
        def rota_W(self):
                self.number[0],self.number[3],self.number[5],self.number[2] = self.number[3],self.$
        def rota_N(self):
                self.number[0],self.number[4],self.number[5],self.number[1] = self.number[4],self.$

        def get_top(self):
                return self.number[0]
data = list(map(int,input().split()))
opt = input()

mydice = Dice(data)
print(mydice.number)
for c in range(len(opt)):
        print(opt[c])
        if(opt[c] == "S"):      mydice.rota_S()
        elif(opt[c] == "E"):    mydice.rota_E()
        elif(opt[c] == "W"):     mydice.rota_W()
        elif(opt[c] == "N"):     mydice.rota_N()
        else: print("something error")
print(mydice.get_top())



### FIXED CODE ###

class dice:
    def __init__(self, pip):
        self.pip = pip
        
    def move(self,dir):
        if str(dir) == "E":
            self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[3],self.pip[0],self.pip[5],self.pip[2]
        elif str(dir) == "W":
            self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[2],self.pip[5],self.pip[0],self.pip[3]
        elif str(dir) == "N":
            self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[1],self.pip[5],self.pip[0],self.pip[4]
        elif str(dir) == "S":
            self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[4],self.pip[0],self.pip[5],self.pip[1]

d = dice(list(map(int,input().split())))
inp = list(input())

for dir in inp:
    d.move(dir)

print(d.pip[0])
import sys
import math

r = int(sys.stdin.readline())
print("%f %f" % (r*r*math.pi, r*2*math.pi))

### FIXED CODE ###

import sys
import math

r = float(sys.stdin.readline())
print("%f %f" % (r*r*math.pi, r*2*math.pi))
#151c
n,w=map(int,input().split())
ac=0
wa=0
wa_cnt=0
ac_flg=[0]*n
for i in range(w):
	p=int(input())-1
	s=input()
	if ac_flg[p]==1:
		continue
	else:
		if s=='AC':
			ac_flg[p]=1
			ac+=1
			wa+=wa_cnt
		else:
			wa_cnt+=1
print(ac,wa)

### FIXED CODE ###

#151c
n,w=map(int,input().split())
ac=0
wa=[0]*n
wa_cnt=[0]*n
ac_flg=[0]*n
for i in range(w):
	p,s=input().split()
	p=int(p)-1
	if ac_flg[p]==1:
		continue
	else:
		if s=='AC':
			ac_flg[p]=1
			ac+=1
			wa[p] =wa_cnt[p]
			#wa_cnt=0
		else:
			wa_cnt[p]+=1

wa_ans=0
for i in range(n):
	wa_ans+=wa[i]

print(ac,wa_ans)
import sys


def euc(n,m):
    if n%m == 0:
        return m
    else:
        return euc(min(n,m), max(n,m)%min(n,m))


for line in sys.stdin:
    a,b = [int(i) for i in line.split()]
    print(euc(a,b),int(a*b/euc(a,b)))



### FIXED CODE ###

import sys


def euc(n,m):
    if max(n,m)%min(n,m) == 0:
        return min(n,m)
    else:
        return euc(min(n,m), max(n,m)%min(n,m))


for line in sys.stdin:
    a,b = [int(i) for i in line.split()]
    print(euc(a,b),int(a*b/euc(a,b)))
N = input()
L = list(map(int,input().split()))
Ma1 = max(L)

Su1 = sum(L)

hikaku = Su1 - Ma1

if hikaku > ma1:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N = input()
L = list(map(int,input().split()))
Ma1 = max(L)
 
Su1 = sum(L)
 
hikaku = Su1 - Ma1
 
if hikaku > Ma1:
  print('Yes')
else:
  print('No')
N, M = map(int, input().split())

R = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    R[a-1].append(b-1)
    R[b-1].append(a-1)

from collections import deque
def bfs(u):
    
    q = deque()
    q.append(u)
    while q:
        r = q.pop()
        for v in R[r]:
            if V[v]:
                V[v] = False
                S[v] = r
                q.append(v)

bfs(0)
print("Yes")
for i in range(1,N):
    print(S[i]+1)

### FIXED CODE ###

from collections import deque

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

R = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    R[a-1].append(b-1)
    R[b-1].append(a-1)

def bfs(u):
    
    q = deque()
    q.append(u)
    while q:
        r = q.popleft()
        for v in R[r]:
            if S[v] == -1:
                S[v] = r
                q.append(v)

S = [-1] * N
S[0] = 0

bfs(0)

print("Yes")
for i in range(1,N):
    print(S[i]+1)