(n,m),*e=[[*list(map(int, t.split()))] for t in open(0)]

t=[[]for _ in range(n+1)]

for a,b in e:t[a]+=[b];t[b]+=[a]

q=[1]

a=[0]*-~n

while q:q=[a[j]==0and(a.__setitem__(j,i)or j)for i in q for j in t[i]]

print(('Yes',*a[2:]))

(n, m), *e = [[*list(map(int, t.split()))] for t in open(0)]

q = [1]

ans = [0] * -~n

node = [[] for _ in range(-~n)]

temp = set()



for i, j in e:

    node[i].append(j)

    node[j].append(i)



while q:

    for x in q:

        for y in node[x]:

            if ans[y] == 0:

                ans[y] = x

                temp.add(y)

    q = list(temp)

    temp.clear()



if 0 in ans[2:]:

    print('No')

else:

    print(('Yes', *ans[2:]))

(n, m), *e = [[*list(map(int, t.split()))] for t in open(0)]
t = [[] for _ in range(n + 1)]
for a, b in e:
    t[a] += [b]
    t[b] += [a]
q = [1]
a = [0] * -~n
while q:
    q = [a[j] == 0 and (a.__setitem__(j, i) or j) for i in q for j in t[i]]
print(("Yes", *a[2:]))

(n, m), *e = [[*list(map(int, t.split()))] for t in open(0)]
q = [1]
ans = [0] * -~n
node = [[] for _ in range(-~n)]
temp = set()
for i, j in e:
    node[i].append(j)
    node[j].append(i)
while q:
    for x in q:
        for y in node[x]:
            if ans[y] == 0:
                ans[y] = x
                temp.add(y)
    q = list(temp)
    temp.clear()
if 0 in ans[2:]:
    print("No")
else:
    print(("Yes", *ans[2:]))

-t = [[] for _ in range(n + 1)] -for a, b in e: -    t[a] += [b] -    t[b] += [a] -a = [0] * -~n +ans = [0] * -~n +node = [[] for _ in range(-~n)] +temp = set() +for i, j in e: +    node[i].append(j) +    node[j].append(i) -    q = [a[j] == 0 and (a.__setitem__(j, i) or j) for i in q for j in t[i]] -print(("Yes", *a[2:])) +    for x in q: +        for y in node[x]: +            if ans[y] == 0: +                ans[y] = x +                temp.add(y) +    q = list(temp) +    temp.clear() +if 0 in ans[2:]: +    print("No") +else: +    print(("Yes", *ans[2:]))