Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

#最長共通部分列
# https://qiita.com/_rdtr/items/c49aa20f8d48fbea8bd2

#比較する文字列
s1 = input()
s2 = input()

table = [[0 for _ in range(len(s1))] for _ in range(len(s2))]

#0行目を埋める
f = 0
for i in range(len(s2)):
    if f or s2[i] == s1[0]:
        table[i][0] = 1
        f = 1

#0列目を埋める
f = 0
for i in range(len(s1)):
    if f or s2[0] == s1[i]:
        table[0][i] = 1
        f = 1


for i in range(1, len(s2)):
    for j in range(1, len(s1)):
        #上マスと左マスは考慮済みなので、左上から遷移する
        if s2[i] == s1[j]:
            table[i][j] += table[i-1][j-1]+1
        else:
            if i == 0 or j == 0:
                continue
            else:
                table[i][j] = max(table[i-1][j], table[i][j-1])

# for col in table:
#     print(col)

#最長文字列を求める
lcs_str = ""
i, j = len(s2)-1, len(s1)-1

while i >= 0 and j >= 0:
    # print("i", i, "j", j)
    if s2[i] == s1[j]:
        # print("c")
        lcs_str += s2[i] #or s2[j-1]
        i -= 1
        j -= 1
    else:
        if j == 0:
            i -= 1
        elif i == 0:
            j -= 1
        else:
            if table[i-1][j] > table[i][j-1]:
                i -= 1
            else:
                j -= 1
print(lcs_str[::-1])

### FIXED CODE ###

#最長共通部分列
# https://qiita.com/_rdtr/items/c49aa20f8d48fbea8bd2

#比較する文字列
s1 = input()
s2 = input()

table = [[0 for _ in range(len(s1))] for _ in range(len(s2))]

#0行目を埋める
f = 0
for i in range(len(s2)):
    if f or s2[i] == s1[0]:
        table[i][0] = 1
        f = 1

#0列目を埋める
f = 0
for i in range(len(s1)):
    if f or s2[0] == s1[i]:
        table[0][i] = 1
        f = 1


for i in range(1, len(s2)):
    for j in range(1, len(s1)):
        #上マスと左マスは考慮済みなので、左上から遷移する
        if s2[i] == s1[j]:
            table[i][j] += table[i-1][j-1]+1
        else:
            if i == 0 or j == 0:
                continue
            else:
                table[i][j] = max(table[i-1][j], table[i][j-1])

# for col in table:
#     print(col)

#最長文字列を求める
lcs_str = ""
i, j = len(s2)-1, len(s1)-1

while i >= 0 and j >= 0:
    # print("i", i, "j", j)
    if s2[i] == s1[j]:
        # print("c")
        lcs_str += s2[i] #or s2[j-1]
        i -= 1
        j -= 1
    else:
        if j == 0:
            i -= 1
        elif i == 0:
            j -= 1
        else:
            if table[i-1][j] > table[i][j-1]:
                i -= 1
            else:
                j -= 1
print(lcs_str[::-1])
### BUGGY CODE ###

def f():
     n,m = map(int,input().split())
     a = list(map(int,input().split()))
     for i in range(m):
          b,c = map(int,input().split())
          a += [c]*b
     ans = 0
     for i in range(n):
          s = max(a)
          ans += s
          a.remove(s)
     print(ans)

f()

### FIXED CODE ###

def f(n,m):
     a = list(map(int,input().split()))
     min_a = min(a)
     a = [(1,i) for i in a]
     b_c = [tuple(map(int,input().split())) for i in range(m)]
     a += b_c
     a.sort(key=lambda x:x[1])
     ans = 0
     while True:
          if n>a[-1][0]:
               ans += a[-1][0]*a[-1][1]
               n -= a[-1][0]
               a.pop()
          else:
               ans += a[-1][1]*n
               break
     print(ans)

n,m = map(int,input().split())
f(n,m)
### BUGGY CODE ###

from itertools import product
from random import randint

def sol():
    N = int(input())
    XYP = [tuple(map(int, input().split())) for _ in range(N)]
    XYP.sort(key=lambda xyp: xyp[2], reverse=randint(0, 3)==0)

    X = [x for x, _, _ in XYP]
    Y = [y for _, y, _ in XYP]
    INF = 10**18

    def calcCost(AP, A):
        ret = [[INF] * N for _ in range(1 << N)]
        for state in range(1 << N):
            useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
            for i, (a, p) in enumerate(AP):
                cost = abs(a)
                for z in useA:
                    cost = min(cost, abs(a - z))
                ret[state][i] = cost * p
        return ret

    costX = calcCost([(x, p) for x, _, p in XYP], X)
    costY = calcCost([(y, p) for _, y, p in XYP], Y)

    ans = [INF] * (N + 1)
    for state in product((0, 1, 2), repeat=N):
        stateX = 0
        stateY = 0
        M = N
        for s in state:
            stateX <<= 1
            stateY <<= 1
            if s == 0: M -= 1
            if s == 1: stateX |= 1
            if s == 2: stateY |= 1

        cx, cy = costX[stateX], costY[stateY]
        cost = 0
        for i in range(N):
            cost += min(cx[i], cy[i])
            if cost >= ans[M]:
                break
        else:
            ans[M] = cost

    print(*ans, sep='\n')

sol()

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
from numba import njit
import numpy as np
INF = 10**18

@njit('(i8, i8[:,:])')
def solve(N, XYP):
    X = XYP[:, 0]
    Y = XYP[:, 1]

    def calcCost(sign, A):
        ret = np.ones((1 << N, N), dtype=np.int64) * INF
        for state in range(1 << N):
            useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
            for i in range(N):
                xyp = XYP[i]
                cost = abs(xyp[sign])
                for z in useA:
                    cost = min(cost, abs(xyp[sign] - z))
                ret[state][i] = cost * xyp[2]
        return ret

    costX = calcCost(0, X)
    costY = calcCost(1, Y)
    ans = np.ones(N + 1, dtype=np.int64) * INF

    for state in range(pow(3, N)):
        stateX = 0
        stateY = 0
        M = N
        for _ in range(N):
            state, r = divmod(state, 3)
            stateX <<= 1
            stateY <<= 1
            if r == 0: M -= 1
            if r == 1: stateX |= 1
            if r == 2: stateY |= 1

        cx, cy = costX[stateX], costY[stateY]
        cost = 0
        for i in range(N):
            cost += min(cx[i], cy[i])
        ans[M] = min(ans[M], cost)

    for a in ans:
        print(a)

def sol():
    N = int(input())
    XYP = np.asarray([list(map(int, input().split())) for _ in range(N)])
    solve(N, XYP)

sol()
### BUGGY CODE ###

S = input()

S = [s for s in S]

out = [0] * len(S)
# 今R, 右に何ステップでL


for i, n in enumerate(S):
    if n == 'R':
        found = False
        cnt = 1

        while not found:
            if S[i + cnt] == 'L':
                found = True
            else:
                cnt += 1

        if cnt % 2 == 0:
            out[i + cnt] += 1
        else:
            out[i + cnt - 1] += 1

    else:
        found = False
        cnt = 1

        while not found:
            if S[i - cnt] == 'R':
                found = True
            else:
                cnt += 1

        if cnt % 2 == 0:
            out[i - cnt] += 1
        else:
            out[i - cnt + 1] += 1


out1 = [str(n) for n in out]

print(' '.join(out1))

### FIXED CODE ###

S = input()
S = [s for s in S]

out = [0] * len(S)

if S[0] == 'R':
    top_R = True
    top_L = False
else:
    top_R = False
    top_L = True

for i, n in enumerate(S):
    if n == 'R':
        if top_R:
            found = False
            cnt = 1
            while not found:
                if S[i + cnt] == 'L':
                    found = True
                else:
                    cnt += 1
            top_R = False
        else:
            cnt -= 1

        if cnt % 2 == 0:
            out[i + cnt] += 1
        else:
            out[i + cnt - 1] += 1

        if cnt != 1:
            top_R = False
        else:
            top_L = True
    else:
        if top_L:
            found = False
            cnt = 1
            while not found:
                if S[i - cnt] == 'R':
                    found = True
                else:
                    cnt += 1
            top_L = False
        else:
            cnt += 1

        if cnt % 2 == 0:
            out[i - cnt] += 1
        else:
            out[i - cnt + 1] += 1

        if cnt != 1:
            top_L = False
        else:
            top_R = True

out1 = [str(n) for n in out]
print(' '.join(out1))
### BUGGY CODE ###

N=int(input())

X=[]
for i in range(N):
  a=input().split()
  X.append([int(a[0]),int(a[1])])


import math

a=X[0][0]
b=X[0][1]

for i in range(1,N):
  c=X[i][0]
  d=X[i][1]
  a1=a*d/c
  if a1<b:
    y=math.ceil(a/c)*d-b
  else:
    y=math.ceil(a/c)*d-b

  while y<0:
    y+=d


  x=c*(b+y)//d-a
 
  #print("i = "+str(i)+" a = "+str(a)+" b = "+str(b)+" c = "+str(c)+" d = "+str(d)+" x = "+str(x)+" y = "+str(y))
  a=a+x
  b=b+y
print(a+b)

### FIXED CODE ###

N=int(input())
 
X=[]
for i in range(N):
  a=input().split()
  X.append([int(a[0]),int(a[1])])
 
 
a=X[0][0]
b=X[0][1]
 
for i in range(1,N):
  c=X[i][0]
  d=X[i][1]
 

  x= (a + (c - 1)) // c
  y= (b + (d -1)) // d
  
  a1=1000000000000000000
  b1=1000000000000000000
  a2=1000000000000000000
  b2=1000000000000000000
  if d*x-b>=0:
    a1=c*x
    b1=d*x
 
  
  if c*y-a>=0:
    a2=c*y
    b2=d*y
  if (a1+b1)<(a2+b2):
    a=a1
    b=b1
  else:
    a=a2
    b=b2
 
  #print("i = "+str(i)+" a = "+str(a)+" b = "+str(b)+" a1 = "+str(a1)+" b1 = "+str(b1)+" a2 = "+str(a2)+" b2 = "+str(b2)+" c = "+str(c)+" d = "+str(d))
  
 
 
 
 
  
print(a+b)
### BUGGY CODE ###

from bisect import bisect_left as bl
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
for i in range(m):
    b,c=map(int,input().split())
    t=bl(a,c)
    if t<=b:
        a=[c]*t+a[t:]
    else:
        a=a[b:t]+[c]*b+a[t:]
print(sum(a))

### FIXED CODE ###

n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
k=sorted([list(map(int,input().split()))for i in range(m)],key=lambda x:-x[1])+[[0,0]]
c,d=0,0
t=0
ans=0
while c<n:
    if a[d]>=k[t][1]:
        ans+=a[d]
        d+=1
        c+=1
    else:
        ans+=k[t][1]*min(n-c,k[t][0])
        c+=k[t][0]
        t+=1
print(ans)
### BUGGY CODE ###

R,G,B,N = map(int,input().split())
rmax = N // R
gmax = N // G
bmax = N // B
ans = 0
for r in range(rmax+1):
    for g in range(gmax+1):
        if (N - (R*r + G*g)) % B == 0:
            if 0 <= (N - (R*r + G*g) )// B <= bmax: 
                ans += 1
print(ans)

### FIXED CODE ###

R,G,B,N = map(int,input().split())
rmax = N // R
gmax = N // G
bmax = N // B
ans = 0
for r in range(rmax+1):
    for g in range(gmax+1):
        if (N - (R*r + G*g)) % B == 0 and 0 <= (N - (R*r + G*g) )// B <= bmax: 
            ans += 1
print(ans)
### BUGGY CODE ###

import sys

d = [0] * 26
def judge(n, t):
    res = 0
    for i in range(1, n + 1):
        today = t[i - 1] - 1
        res += S[i - 1][today]
        for j, dd in enumerate(d):
            if today != j:
                res -= C[j] * (i - dd)
    return res

D = int(input())
C = list(map(int, sys.stdin.readline().rsplit()))
S = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(D)]

d = [0] * 26
res = 0
tt = []
for i in range(1, D + 1):
    maxi = 0
    for j in range(26):
        tt.append(j + 1)
        jg = judge(i, tt)
        if maxi < jg:
            maxT = j + 1
            maxi = jg
        tt.pop()
    d[maxT - 1] = i
    tt.append(maxT - 1)
    print(maxT)


### FIXED CODE ###

import sys

D = int(input())
C = list(map(int, sys.stdin.readline().rsplit()))
S = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(D)]

d = [0] * 26
res = 0
for i in range(D):
    index = max(enumerate(S[i]), key=lambda x: x[1])[0]
    print(index + 1)
### BUGGY CODE ###

from collections import deque, defaultdict
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
adj = [[] for _ in range(N+1)]
for _ in range(M):
    p, q, c = map(int, input().split())
    adj[p].append((q, c))
    adj[q].append((p, c))

deq = deque()
cost = [10 ** 7] * (N+1)
seen = [defaultdict(int) for _ in range(N+1)]
prev = defaultdict(list)
deq.append(1)
cost[1] = 0
while deq:
    v = deq.pop()
    for uc in adj[v]:
        u, c = uc
        # print(v, u, c)
        # print(deq, prev, cost)
        # print(seen[4])
        if c in prev[v] and seen[u][c] == 0:
            if cost[u] == cost[v]:
                prev[u].append(c)
                deq.append(u)
            elif cost[u] > cost[v]:
                cost[u] = cost[v]
                deq.append(u)
                prev[u] = [c]
            seen[v][c] = 1
        else:
            if cost[u] > cost[v] + 1:
                cost[u] = cost[v] + 1
                deq.appendleft(u)
                prev[u] = [c]
            elif cost[u] == cost[v] + 1:
                prev[u].append(c)

print(cost[N]) if cost[N] < 10 ** 7 else print(-1)


### FIXED CODE ###

def main():
    import sys
    from collections import deque
    input = sys.stdin.readline

    N, M = map(int, input().split())
    adj = [[] for _ in range(N+1)]
    c2v = {}
    v = N+1
    for _ in range(M):
        p, q, c = map(int, input().split())
        P = p*(10**7) + c
        Q = q*(10**7) + c
        if P not in c2v:
            c2v[P] = v
            adj[p].append((v, 1))
            adj.append([(p, 1)])
            v += 1
        if Q not in c2v:
            c2v[Q] = v
            adj[q].append((v, 1))
            adj.append([(q, 1)])
            v += 1
        adj[c2v[P]].append((c2v[Q], 0))
        adj[c2v[Q]].append((c2v[P], 0))

    que = deque()
    que.append(1)
    seen = [-1] * len(adj)
    seen[1] = 0
    while que:
        v = que.popleft()
        for u, cost in adj[v]:
            if seen[u] == -1:
                seen[u] = seen[v] + cost
                if cost:
                    que.append(u)
                else:
                    que.appendleft(u)
    print(seen[N] // 2)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

R,G,B,N = map(int,input().split())

# R,G,B = reversed([R,G,B])
r = 0
count = 0
r_max = N // R

while r <= r_max:
    
    g_max = (N-r*R)//G
    g = 0
    while g <= g_max:
        b = (N-r*R-g*G)/B
        if b.is_integer() and b >= 0:
            count += 1

        g += 1
    
    r += 1

print(count)

### FIXED CODE ###

R,G,B,N = map(int,input().split())

count = 0
for r in range(0,N+1,R):
    for g in range(r,N+1,G):
        b = (N-g)/B
        if b.is_integer() and b >= 0:
            count += 1

print(count)
### BUGGY CODE ###

from math import *

def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors

def eratosthenes(n):
    table = [0] * (n + 1)
    prime_list = []
    
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
                
    return prime_list

a,b = map(int,input().split())
upper = 10**8
ans = set(eratosthenes(upper)) & make_divisors(a) & make_divisors(b)
print(len(ans) + 1)

### FIXED CODE ###

def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b,e))
        b,e = b+1,0
    if n > 1:
        fct.append((n,1))
    return fct
a,b = map(int,input().split())
ap = set()
for prime,count in factorize(a):
    ap.add(prime)
bp = set()
for prime,count in factorize(b):
    bp.add(prime)
print(len(ap&bp)+1)
### BUGGY CODE ###

N = int(input())
A = []
A = input().split()
A = [int(n) for n in A]

B = [int(0) for n in range(N)]

for i in range(N) :
  for j in range(N) :
    if i+1 == A[j] :
      B[i] = j+1
      break
  

#print('N', N)
#print('A', A)
#print('B', B)

B = [str(n) for n in B]

result = ' '.join(B)

print(result)


### FIXED CODE ###

N = int(input())
A = []
A = input().split()
A = [int(n) for n in A]

B = [int(0) for n in range(N)]

for i in range(N) :
  B[A[i]-1] = i+1
#  B[i] = A.index(i+1) + 1


#print('N', N)
#print('A', A)
#print('B', B)

B = [str(n) for n in B]

result = ' '.join(B)

print(result)
### BUGGY CODE ###

#d
n=int(input())
x=list(input())

def popcount(m):
    return bin(m).count("1")

popcount0 = popcount(int( "0b"+"".join(x) ,0 ))

jisho = ["yet"]*n

for i in range(n):
    xx = x[:]
    if xx[i]=="0":
        xx[i] = "1"
        pop = popcount0+1
    else:
        xx[i] = "0"
        pop = popcount0-1
        
    intxi = int( "0b"+"".join(xx) ,0 )
#    print(intxi,intxi%pop)
    if intxi==0:
        print(0)
        continue
    else:
        c=0
        while intxi!=0:
            if c==0:
                intxi=intxi%pop
            else:
                if jisho[intxi]=="yet":
                    togo = intxi%popcount(intxi)
                    jisho[intxi]= togo
                    intxi = togo
                else:
                    intxi =jisho[intxi]
                
            #print(m)
            c+=1
        print(c)
#        print("f(n)=",c)

### FIXED CODE ###

#d 
n=int(input())
x=input()

def popcount(m):
    return bin(m).count("1")

intx = int( "0b"+x ,0 )
popcount0 = x.count("1")

intx_mod_pp1 = intx %(popcount0+1)
if popcount0!=1:
    intx_mod_pm1 = intx %(popcount0-1)
    

jisho = ["yet"]*n
# pow2ip = .5
# pow2im = .5

for i in range(n):
    if x[i]=="1" and popcount0==1:
        print(0)
        continue
    
    pow2ip = pow(2,n-i-1,popcount0+1)
    if popcount0!=1:
        pow2im = pow(2,n-i-1,popcount0-1)

    if False:
        pass
    
    
    else:
        intxi=1
        c=0
        while intxi!=0:
            if c==0:
                if x[i]=="0":
                    pop = popcount0+1
                    intxi = (intx_mod_pp1 + pow2ip%pop )%pop
                else:
                    pop = popcount0-1
                    intxi = (intx_mod_pm1 - pow2im%pop )%pop        
            else:
                if jisho[intxi]=="yet":
                    togo = intxi%popcount(intxi)
                    jisho[intxi]= togo
                    intxi = togo
                else:
                    intxi =jisho[intxi]
                
            #print(intxi)
            c+=1
        print(c)
        #print()
    
#        print("f(n)=",c)
### BUGGY CODE ###

# import numpy as np
A, B = map(int, input().split())

# ans = A
# for i in range(A+1,B+1,1):
#     ans = ans^i
# print(ans)
# counter = 0

# list = np.zeros(50)
# for i in range(A,B+1,1):
#     list += np.array(list(map(int, str(i))).reverse())
# for i in range(len(list)):
#     list[i] = list[i]%2
# list.reverse()
# print(list)

l = [0]*100
s = ''
for i in range(A,B+1,1):
    bi = bin(i)[2:]
    # print(bi)
    for j in range(1,len(bi)+1):
        if bi[-j] == '1':
            l[j] = (l[j]+1)%2

for i in range(len(l)):
    s = s + str(l[-i])
print(int(s, 2))


### FIXED CODE ###

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

def XOR(A):
    # 0からAまでの排他的論理和を求める
    if A%4 == 0:
        return A
    elif A%4 == 2:
        return A+1
    elif A%4 == 1:
        return 1
    else:
        return 0

fA = XOR(A-1)
fB = XOR(B)
print(fB^fA)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
N = int(input())
P = list(map(int, input().split()))
ans=0
for i in range(N-1,-1,-1):
    M=min(P)
    if P[i] ==M:
        ans+=1
    del P[-1]
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
N = int(input())
P = list(map(int, input().split()))
ans=1
if N!=1:
    M=P[0]
    for i in range(1,N,1):
        M=min(P[i],M)
        if P[i] ==M:
            ans+=1
print(ans)
### BUGGY CODE ###

import sys
import numpy as np

def retmin(a, b):
    if a > b:
        return b
    return a

# N 足場の数、K カエルができる行動
n, k = map(int, input().split())

# H 各足場の高さ
h = list(map(int, input().split()))

# 初期化
dp = np.full(100100, 1000000000)
dp[0] = 0

for i in range(n):
    for j in range(k):
        if (i + j < n):
            dp[i+j] = retmin(dp[i+j], abs(h[i+j]-h[i-1])+dp[i-1])
print(int(dp[n-1]))

### FIXED CODE ###

import sys
import numpy as np

input = sys.stdin.readline

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

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

# 初期化
dp = np.zeros(n, dtype=int)

for i in range(1, n):
    start = max(0, i-k)
    dp[i] = min(dp[start:i] + np.abs(h[i] - h[start:i]))
print(dp[n-1])
### BUGGY CODE ###

L,R=map(int,input().split())
ans=2018
if R-L>=2019**2:
    R=L+2019**2
for i in range(L,R):
    for j in range(i+1,R+1):
        ans=min(ans,(i*j)%2019)
        if ans==0:
            break
print(ans)

### FIXED CODE ###

L,R=map(int,input().split())
ans=2018
if R-L>=2019**2:
    R=L+2019**2
for i in range(L,R):
    for j in range(i+1,R+1):
        ans=min(ans,(i*j)%2019)
        if ans==0:
            break
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(200005)
n, q = map(int, input().split())

to = [[] for i in range(n+1)]


for i in range(n-1):
    a, b = map(int, input().split())
    to[a].append(b)
    to[b].append(a)

score = [0]*(n+1)
h = [0] * (n+1)
for i in range(q):
    p, x = map(int, input().split())
    h[p] += x


def down_tree(index, parent):
    score[index] += score[parent] + h[index]
    for i in to[index]:
        if i == parent:
            continue
        down_tree(i, index)



down_tree(1, 1)

print(' '.join(map(str, score[1:])))

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(200005)
n, q = map(int, input().split())

to = [[] for i in range(n+1)]


for i in range(n-1):
    a, b = map(int, input().split())
    to[a].append(b)
    to[b].append(a)

score = [0]*(n+1)
for i in range(q):
    p, x = map(int, input().split())
    score[p] += x


def down_tree(index, parent):
    for i in to[index]:
        if i == parent:
            continue
        score[i] += score[index]
        down_tree(i, index)



down_tree(1, 1)

print(' '.join(map(str, score[1:])))
### BUGGY CODE ###

def readinput():
    n,m=list(map(int,input().split()))
    rooms = [
        [[],-1,-1] for _ in range(n)
        ]
    for _ in range(m):
        a,b = list(map(int,input().split()))
        rooms[a-1][0].append(b)
        rooms[b-1][0].append(a)
    return n,m,rooms

def labelNext(target, rooms, nokori, cost):
    oitaList=[]
    idx = list(nokori)
    for ii in idx:
        i = ii-1
        room=rooms[i]
        if (target in room[0]) and (room[1] == -1):
            room[1] = target
            room[2] = cost
            oitaList.append(i+1) # 道しるべをおいた部屋番号のリストにするので+1
    nokori -= set(oitaList)  #　道しるべを置いた部屋番号を削除
    return oitaList

def main(n,m,rooms):
    nokori=set(range(2,n+1))  # 道しるべを置いてない部屋番号の集合 (1を除くすべて)
    target=1
    cost=1
    nextList=labelNext(target,rooms, nokori, cost)
    while(len(nokori)>0):
        cost+=1
        nl=[]
        for n in nextList:
            nl.append(labelNext(n,rooms,nokori,cost))
            if(len(nokori)==0):
                break
        nextList=nl
    labelList=[]
    for room in rooms:
        labelList.append(room[1])   
    labelList.pop(0)     
    return labelList

if __name__=='__main__':
    n,m,rooms=readinput()
    labelList=main(n,m,rooms)
    print('Yes')
    for l in labelList:
        print(l)
    

### FIXED CODE ###

from collections import deque

WHITE=0
GRAY=1
BLACK=2

nList = []
labelList = []
color = []
Q = deque([])

def readinput():
    global nList
    global color
    global Q
    global labelList

    n,m=list(map(int,input().split()))
    nList = []
    for _ in range(n+1):
        nList.append([])  # 1-オリジンの隣接リスト

    for _ in range(m):
        a,b = list(map(int,input().split()))
        nList[a].append(b)
        nList[b].append(a)

    labelList = [0]*(n+1)
    color = [WHITE]*(n+1)
    Q = deque([])

    #print(nList)

def bfs(p):
    global Q
    global nList
    global color
    global labelList

    Q.append(p)
    color[p]=GRAY
    #print(Q)
    #print(color)
    while(len(Q)>0):
        current=Q.popleft()
        for next in nList[current]:
            if(color[next]==WHITE):
                Q.append(next)
                color[next]=GRAY
                labelList[next]=current
                #print(Q)
                #print(color)
                #print(labelList)
        color[current]=BLACK

def main():

    bfs(1)


if __name__=='__main__':
    readinput()

    main()
    print('Yes')
    for l in labelList[2:]:
        print(l)