Harryxun/stf_run huggingface dataset:
n,k = map(int, input().split())
A = list(map(int, input().split()))
import collections
res = collections.deque('1')
rep = [0,0]
for i in range(n):
    print(res)
    if str(A[int(res[-1])-1]) not in res:
        res.append(str(A[int(res[-1])-1]))
    else:
        rep[0] = res.index(str(A[int(res[-1])-1]))
        rep[1] = len(res)
        break

#print(res)
#print(rep)
if k < len(res):
    print(res[k])
else:
    rep_num = rep[1] - rep[0]
    remainder = (k-rep[0])%rep_num
    print(res[rep[0] +remainder])

### FIXED CODE ###

n,k = map(int, input().split())
b = list(map(int, input().split()))
a=0
for i in range(n):
    b[i] -= 1
if k<n:
    for i in range(k):
        a = b[a]
    print(a+1)
    exit()
c = [-1]*n
cc = 0
se = set()
while a not in se:
    c[a] = cc
    cc += 1
    se.add(a)
    a = b[a]
for i in range((k-c[a])%(cc-c[a])):
    a = b[a]
print(a+1)
from collections import defaultdict
from collections import deque
from itertools import accumulate
import math
def main():
    a,b=map(float, input().split())
    print(int((a*(b*100))//100))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
from collections import defaultdict
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
          n /= i
          table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def main():
    dd = defaultdict(int)
    n = int(input())
    pri = factorization(n)
    res = 0
    i  = len(pri)-1
    ans = 0

    for i in pri:
        k = i[1]
        i=1
        tmp=2
        cnt = 0
        while i<=k:
            i+=tmp
            tmp+=1
            cnt+=1
        ans+=cnt
    if len(pri)==1 and pri[0][1]==1:
        ans=1
    if n==1:
        ans = 0
    print(ans)


if __name__ == '__main__':
    main()
from bisect import *
N,M=map(int,input().split())
kagi=[]
for i in range(M):
    a,b=map(int,input().split())
    C=list(map(int,input().split()))
    for i in range(b):
        C[i]-=1
    kagi.append([a,set(C)])

value=10**7
idx=-1
for i in range(M):
    if 0 in kagi[i][1] and kagi[i][0]<value:
        value=kagi[i][0]
        idx=i
if idx==-1:
    print(-1)
    exit()
kagilst=[idx]

takara=[set() for i in range(N)]
for m in range(M):
    for k in kagi[m][1]:
        takara[k].add(m)

for n in range(1,N):
    if [k for k in kagilst if n in kagi[k][1]]:
        continue
    tempvalue=10**7
    for k in takara[n]:
        lst=[0 for i in range(n)]
        for z in kagilst+[k]:
            for m in kagi[z][1]:
                if m<len(lst):
                    lst[m]=1
        for i in range(len(kagilst)**2):
            A=bin(i)[:2]
            A=list(reversed(list(A)))
            for i in range(len(A))
            for a in range(len(kagilst)-len(kagilst)):
                A.append("0")
                if A[a]=="1":
                    for h in kagi[kagilst[a]][1]:
                        if h<len(lst):
                            lst[h]=1
            if not 0 in lst:
                temptempvalue=value+sum([kagi[a][0] for a in range(len(kagilst)) if A[a]=="1"])+kagi[k][0]
                if temptempvalue<tempvalue:
                    tempvalue=temptempvalue
                    tempkagi=k
    if tempvalue==10**7:
        print(-1)
        exit()
    value=tempvalue
    kagilst.append(k)
print(value)


### FIXED CODE ###

from bisect import *
N,M=map(int,input().split())
kagi=[]
for i in range(M):
    a,b=map(int,input().split())
    C=list(map(int,input().split()))
    value=0
    for i in range(b):
        C[i]-=1
        value+=2**C[i]

    kagi.append([a,value])


dp=[[10**8 for i in range(2**N)] for m in range(M+1)]
dp[0][0]=0
for i in range(M):
    for s in range(2**N):
        dp[i+1][s]=min(dp[i][s],dp[i+1][s])
        dp[i+1][s|kagi[i][1]]=min(dp[i+1][s|kagi[i][1]],dp[i][s]+kagi[i][0])
if 10**8==dp[M][-1]:
    print(-1)
else:
    print(dp[M][-1])
import collections
n=input()
s=[]
for i in range(n):
    s.append(input())
c=collections.Counter(s).most_common()


print(c[0][0])
mx=c[0][1]
for i in range(1,len(c)):
    if c[i][1]==mx:
        print(c[i][0])
    else:
        exit()
    

### FIXED CODE ###

n = int(input())

s_list = [""]*n

for i in range(n):
    s_list[i] = input()

s_list.sort()

ans_list = [s_list[0]]
pre_s = s_list[0]
count = 1
max_count = count

if len(s_list) == len(set(s_list)):
    ans_list = s_list
        
    ans_list.sort()

    for s in ans_list:
        print(s)

    exit()


for i in range(1,n):
    if pre_s == s_list[i]:
        count += 1
        if count == max_count:
            ans_list.append(s_list[i])
        if count > max_count:
            max_count = count
            ans_list = [s_list[i]]
    else:
        pre_s = s_list[i]
        count = 1

ans_list.sort()

for s in ans_list:
    print(s)
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input)
s=v-w
s*=t
if abs(a-b)<=s:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
s=v-w
s*=t
if abs(a-b)<=s:
  print("YES")
else:
  print("NO")
s = input()

# t = ['dream', 'dreamer', 'erase', 'eraser']

s = s[::-1]
for i in range(4):
    t[i] = t[i][::-1]

# print(s,t)

tmp = s

while tmp != '':
    d = tmp[:5] == 'maerd'
    dr = tmp[:7] == 'remaerd'
    e = tmp[:5] == 'esare'
    er = tmp[:6] == 'resare'
    # print(tmp[:5])
    # print(d,dr,e,er)

    if d:
        tmp = tmp[5:]
    elif e:
        tmp = tmp[5:]
    elif dr:
        tmp = tmp[7:]
    elif er:
        tmp = tmp[6:]
    else:
        print('NO')
        break

if tmp == '':
    print('YES')


### FIXED CODE ###

s = input()

# t = ['dream', 'dreamer', 'erase', 'eraser']

s = s[::-1]
# for i in range(4):
#     t[i] = t[i][::-1]

# print(s,t)

tmp = s

while tmp != '':
    d = tmp[:5] == 'maerd'
    dr = tmp[:7] == 'remaerd'
    e = tmp[:5] == 'esare'
    er = tmp[:6] == 'resare'
    # print(tmp[:5])
    # print(d,dr,e,er)

    if d:
        tmp = tmp[5:]
    elif e:
        tmp = tmp[5:]
    elif dr:
        tmp = tmp[7:]
    elif er:
        tmp = tmp[6:]
    else:
        print('NO')
        break

if tmp == '':
    print('YES')
A = list(map(int,input().split(" ")))
H = list()
C = list()
result = list()
for i in range(A[0]):
    H.append(list(map(int,input().split(" "))))
for i in range(A[1]):
    C.append(list(map(int,input().split(" "))))
    
for i in range(A[0]):
    res = 0
    tmp = 99999999
    for ii in range(A[1]):
        if tmp > abs(H[i*2-1] - C[i*2-1]) + abs(H[i*2] - C[i*2]):
            res = ii
    result.append(res)

for i in range(A[1]):
    print(result[i])


### FIXED CODE ###

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

for i in range(a[0]):
    b.append(list(map(int,input().split(" "))))

for i in range(a[1]):
    c.append(list(map(int,input().split(" "))))

for i in range(a[0]):
    d = 0
    e = 9999999999
    for ii in range(a[1]):
        if e > abs(b[i][0] - c[ii][0]) + abs(b[i][1] - c[ii][1]):
            e = abs(b[i][0] - c[ii][0]) + abs(b[i][1] - c[ii][1])
            d = ii
    ans.append(d+1)
    
for i in range(a[0]):
    print(ans[i])
mondai = input(),split()
if mondai.count('5')==2 and mondai.count('7')==1:print('Yes')
else:print('No')

### FIXED CODE ###

x = input().split()
five = x.count('5')
seven = x.count('7')
if five==2 and seven==1:print('YES')
else:print('NO')
s=input()
q=int(input())
l = [list(input().split()) for i in range(q)]
c=0
for i in range(q):
  if l[i][0]=="1":
    c+=1
  elif c%2=0 and l[i][1]=="1":
    s=l[i][2]+s
  elif c%2=0:
    s=s+l[i][2]
  elif c%2=1 and l[i][1]=="1":
    s=s+l[i][2]
  else:
    s=l[i][2]+s
if c%2=1:
  s=s[::-1]
print(s)

### FIXED CODE ###

from collections import deque
s=deque(list(input()))
q=int(input())
l = [list(input().split()) for i in range(q)]
c=0
for i in range(q):
  if l[i][0]=="1":
    c+=1
  elif c%2==0 and l[i][1]=="1":
    s.appendleft(l[i][2])
  elif c%2==0:
    s.append(l[i][2])
  elif c%2==1 and l[i][1]=="1":
    s.append(l[i][2])
  else:
    s.appendleft(l[i][2])
s=list(s)
if c%2==1:
  s=s[::-1]
print(*s, sep="")
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

def main()
    n=n0()
    a=n1()

    from math import factorial
    def comb(n):
        if n<=1:
            return 0
        if n==2:
            return 1
        return factorial(n)//(factorial(2)*factorial(n-2))

    c=[a.count(i) for i in range(1,n+1)]
    d=[comb(m) for m in c]
    s=sum(d)

    for i in range(n):
        print(s-d[a[i]-1]+comb(c[a[i]-1]-1))
if __name__ == '__main__':
	main()

### FIXED CODE ###

def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
a=n1()

def comb(n):
    if n<=1:
        return 0
    if n==2:
        return 1
    return (n*(n-1))//2

from collections import Counter
c=Counter(a)
# print(c)
d={i:comb(j) for i,j in c.items()}
# print(d)
s=sum(d.values())
# print(s)

for i in a:
    print(s-d[i]+comb(c[i]-1))
H,W = map(int,input().split())
h,w = map(int,input().split())
TOTAL = H * W
total = h * w
result = TOTAL - total
print(resurt)

### FIXED CODE ###

H,W = map(int,input().split())
h,w = map(int,input().split())
TOTAL = H * W
total = (W * h + H * w)-h*w
result = TOTAL - total
print(result)
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n, m, q = LI()
    abcd = LIR(q)
    ans = 0
    fulls = itertools.combinations_with_replacement(range(m),m)
    for full in fulls:
        tmp = 0
        for a, b, c, d in abcd:
            if full[b-1] - full[a-1] == c:
                tmp += d
        ans = max(tmp, ans)
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n, m, q = LI()
    abcd = LIR(q)
    ans = 0
    fulls = itertools.combinations_with_replacement(range(m),n)
    for full in fulls:
        tmp = 0
        for a, b, c, d in abcd:
            if full[b-1] - full[a-1] == c:
                tmp += d
        ans = max(tmp, ans)
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()
A, B, C, K = map(int, input().split())
if A >= K:
  print(K)
elif A + B >= K:
  print(A)
else:
  print(A = (K - A - B))

### FIXED CODE ###

A, B, C, K = map(int, input().split())
if A >= K:
  print(K)
elif A + B >= K:
  print(A)
else:
  print(A - (K - A - B))
n=int(input())
a=list(int,input().split(), for _ in range(0,n))
x=max(a)
y=a.index(x)
del a[y]
z=max(a)

for i in range(0,n):
  if i!=y:
    print(x)
  else:
    print(z)
  


### FIXED CODE ###

n=int(input())
a=[]

for j in range(0,n):
  a.append(int(input()))
  
x=max(a)
y=a.index(x)
del a[y]
z=max(a)

for i in range(0,n):
  if i!=y:
    print(x)
  else:
    print(z)
from sys import stdin
import sympy as sp

K = int(stdin.readline().rstrip())
[A, B] = [int(x) for x in input().rstrip().split()]


flag=0
K_temp=K
while(True):
    if(K_temp>B):
        break
    if(K_temp>=A and K_temp<=B):
        flag=1
        break
    else:
        K_temp+=K

if flag==1:
    print("OK")
else:
    print("NG")

### FIXED CODE ###

from sys import stdin

K = int(stdin.readline().rstrip())
[A, B] = [int(x) for x in input().rstrip().split()]


flag=0
K_temp=K
while(True):
    if(K_temp>B):
        break
    if(K_temp>=A and K_temp<=B):
        flag=1
        break
    else:
        K_temp+=K

if flag==1:
    print("OK")
else:
    print("NG")
return 'bust' if a+b+c>=22 else 'win'

### FIXED CODE ###

a=input()
lst = [int(e) for e in a.split(' ')]

print('bust'if sum(lst)>=22 else 'win')
n = raw_input()
a = n.split(" ")
b = int(a[0])
c = int(a[1])
print = b * c
print = (b+c)*2

### FIXED CODE ###

n = raw_input()
a = n.split(" ")
b = int(a[0])
c = int(a[1])
print b*c ,(b+c)*2
N, K = map(int,input().split())
S = [i for i in input()]
S[K-1] = S[K].lower()
print("".join(S))

### FIXED CODE ###

N, K = map(int,input().split())
S = [i for i in input()]
S[K-1] = S[K-1].lower()
print("".join(S))
A,B = map(int, input().split())
print(sum(A,B)%24)

### FIXED CODE ###

A,B = map(int, input().split())
print((A+B) % 24)
import numpy as np
from heapq import heapify,heapreplace
def solve(stdin):
    n,m = stdin[:2]
    A = stdin[2:2+n].tolist()
    BC = stdin[2+n:].reshape(-1,2)

    heapify(A)

    BC = sorted(BC,key=lambda x:(x[1]),reverse=True)
    for b,c in BC:
        if c<A[0]:
            break
        for i in range(b):
            if A[0]>c:
                break
            heapreplace(A,c)
        
    #print(A)
    return sum(A)
 
def main():   
    stdin = np.fromstring(open(0).read(), dtype=np.int64, sep=' ')
    print(solve(stdin))
 
def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
 
if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
    from my_module import solve
    main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    n,m = map(int,input().split())
    A = list(map(int,input().split()))
    BC = [list(map(int,input().split())) for _ in range(m)]

    BC = sorted(BC,key=lambda x:(x[1]),reverse=True)
    append_list = []
    for b,c in BC:
        if len(append_list)>=n:
            break
        append_list+=[c]*b
    A+=append_list
    A.sort(reverse=True)
    print(sum(A[:n]))
if __name__=='__main__':
    main()
S,W=map(int,input().split())

if S>W:
    print("safe")
else:
    print("unsafe"

### FIXED CODE ###

S,W=map(int,input().split())

if S>W:
    print("safe")
else:
    print("unsafe")
# C
import numpy as np

inp = input().split(' ')
N, M = int(inp[0]), int(inp[1])

inps = input().split(' ')
H = np.array([int(inp) for inp in range(len(inps))])
AB = []
for i in range(M):
    inps = input().split(' ')
    AB.append(set([int(inps[0]), int(inps[1])]))
    
def get_height(els):
    return H[els[0]-1] >= H[els[1]-1]

def get_height_sum(arr):
    return np.prod(list(map(get_height, arr)))

def tmp(arr_arr):
    return (list(map(get_height_sum, arr_arr)))

connected = [[[i+1] + list(ab - {i+1}) for ab in AB if i+1 in ab] for i in range(N)]

print(int(tmp(connected)))

### FIXED CODE ###

# C
N, M = map(int, input().split())
H = list(map(int, input().split()))

A = [0] * N
for i in range(M):
    a, b = map(int, input().split())
    A[a-1] = max(A[a-1], H[b-1])
    A[b-1] = max(A[b-1], H[a-1])
    
res = sum([H[i] > A[i] for i in range(N)])
print(res)
n = 500
x, y = map(int, raw_input().split()) 
if x*n >= y: 
  print("Yes")
else: 
  print("No")

### FIXED CODE ###

n = 500
x, y = map(int, input().split())
if x*n >= y: 
    print("Yes")
else: 
    print("No")
N,L=map(int,input())
S=[input() for i in range(N)]
S.sort()
print(*S,sep="")


### FIXED CODE ###

N,L=map(int,input().split())
S=[input() for i in range(N)]
S.sort()
print(*S,sep="")
n,k=map(int,input().split())
h = set(map(int,input().split()))

h = sorted(h)
l = len(h)
for i in range(l-k,l):
  h[i] = 0
  
result = 0  
for j in range(0, l):
  result = result + h[j]
print(result)


### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
for i in range(k):
  try:
    h.pop(-1)
  except IndexError:
    pass
print(sum(h))
N = int(input())
li = list(map(int,input().split()))
li2 = []
key =[0] #key ０でおｋ　１で1下げ
cnt = 0
flg = True
if N == 1:
    ans ="Yes"
    flg = False
while flg :
    cur1 = li[cnt]
    cur2 = li[cnt+1]
    sa = cur2 - cur1
    if key[cnt] == 0:
        if sa < -1:
            ans = "No"
            flg = False
        elif sa == -1:
            key.append(1)
            cnt += 1
        else:
            key.append(0)
            cnt += 1
    else:
        if sa < 0:
            ans = "No"
            flg = False
        else:
            key.append(0)
            cnt += 1
    if cnt == len(li)-1:
        ans = "Yes"
        flg = False
print(ans)

### FIXED CODE ###

A,B,C = map(int,input().split())
A2 = A-B
if A2 >= C:
    ans =0
else:
    ans = C - A2
print(ans)
from collections import defaultdict
import heapq

with open("input.txt","r") as f:
    vertice,edge,source = map(int,f.readline().split(" "))
    link = defaultdict(dict)
    weight = defaultdict(dict)
    for e in range(edge):
        i,j,w = map(int,f.readline().split(" "))
        link[i] = link.get(i,set()) | {j}
        weight[i].update({j:w})
    #print(weight,link)
    for v in range(vertice):
        goal = v
        queue = []
        heapq.heappush(queue,(0,source))
        heapq.heapify(queue)
        went = set()

        while queue != []:
            #print(queue)
            now_cost,here = heapq.heappop(queue)
            #print(now_cost,here,queue)
            if here == goal:
                print(now_cost)
                break

            can_go = link[here]
            not_went = set(can_go) - went
            #print(v,here,now_cost,not_went,queue)
            for nw in not_went:
                next_cost = now_cost + weight[here][nw]
                heapq.heappush(queue,(next_cost,nw))
            went = went | {here}
        else:
            print("INF")

### FIXED CODE ###

import sys
from heapq import heappush, heappop
readline = sys.stdin.readline
from collections import defaultdict
vertices, edges, start = map(int, readline().split())
connect = defaultdict(list)
cost = defaultdict(dict)
answer = ["INF" for n in range(vertices)]
for _ in range(edges):
    s, t, w = map(int, readline().split())
    connect[s].append(t)
    cost[s].update({t:w})
 
 
now = start
weight = 0
p_queue = []
heappush(p_queue, (0, now))
visited = set()
while p_queue:
    weight, now = heappop(p_queue)
    if now in visited:
        continue
    visited |= {now}
    answer[now] = weight
    for c in connect[now]:
        if c not in visited:
            heappush(p_queue, (weight + cost[now][c], c))
for a in answer:
    print(a)
N, D = int(input())
x = [list(map(int, input().split())) for _ in range(N)]
s = 0
for i in range(N - 1) :
    for j in range(i + 1, N) :
        l = 0.0
        for d in range(D) :
            l += (x[i][d] - x[j][d]) ** 2
        length = l ** (1/2)
        if length.is_integer() :
            s += 1
print(s)

### FIXED CODE ###

N, D = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]
s = 0
for i in range(N - 1) :
    for j in range(i + 1, N) :
        l = 0.0
        for d in range(D) :
            l += (x[i][d] - x[j][d]) ** 2
        length = l ** (1/2)
        if length.is_integer() :
            s += 1
print(s)
N = int(input())
if N % 1000 = 0:
  print(0)
else:
  a = N % 1000
  print(1000 - a)

### FIXED CODE ###

N = int(input())
if N % 1000 == 0:
  print(0)
else:
  a = N % 1000
  print(1000 - a)
l = list(map(input().split()))
if l[0] == l[1] == l[2]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

l = list(map(int,input().split()))
if l[0] == l[1] and l[1] == l[2]:
  print("Yes")
else:
  print("No")
N = int(input())
arr = list(map(int,input().split()))

arr.sort()
res = 1
flg = True
for i in arr:
    res*=i
    if res >10**18:
        flg = False
        print('-1')
    # print(res, res >=10**18)
if(flg):print(res)


### FIXED CODE ###

A,B = map(int,input().split())
print(A*B)
from collections import deque

N, M = [int(s) for s in input().split()]
edge = [[int(s) - 1 for s in input().split()] for _ in range(M)]
graph = [[] for _ in range(M)]
for i, j in edge:
    graph[i].append(j)
    graph[j].append(i)

dq = deque([0])
visited = [False] * N
visited[0] = True
parent = [0]*N
while(dq):
    search_obj = dq.pop()
    for candidate_obj in graph[search_obj]:
        if not visited[candidate_obj]:
            dq.appendleft(candidate_obj)
            parent[candidate_obj] = search_obj
            visited[candidate_obj] = True

total_visited = sum(visited)
if total_visited < N:
    print('No')
else:
    print('Yes')
    for i in range(1, N):
        print(parent[i]+1)

### FIXED CODE ###

from collections import deque

N, M = [int(s) for s in input().split()]
edge = [[int(s) - 1 for s in input().split()] for _ in range(M)]
graph = [[] for _ in range(N)]
for i, j in edge:
    graph[i].append(j)
    graph[j].append(i)

dq = deque([0])
visited = [False] * N
visited[0] = True
parent = [0]*N
while(dq):
    search_obj = dq.pop()
    for candidate_obj in graph[search_obj]:
        if not visited[candidate_obj]:
            dq.appendleft(candidate_obj)
            parent[candidate_obj] = search_obj
            visited[candidate_obj] = True

total_visited = sum(visited)
if total_visited < N:
    print('No')
else:
    print('Yes')
    for i in range(1, N):
        print(parent[i]+1)
a,b=map(int,input().split())
s=(a+b)/2
if s%1==0:
  print(s)
else:
  print(IMPOSSIBLE)

### FIXED CODE ###

a,b=map(int,input().split())
c=(a+b)/2
if c%1==0:
    print(int(c))
else:
    print('IMPOSSIBLE')