n,m=list(map(int,input().split()))

marks = {i+1:-1 for i in range(n)}

marks[1] = 0

roots = {i+1:[] for i in range(n)}

count = 0

for i in range(m):

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

    roots[a].append(b)

    roots[b].append(a)



before_room = 1

searchs = [{'root':roots[1], 'mark':1}]

while searchs != []:

    next_search = []

    for search in searchs:

        for root in search['root']:

            new_root = []

            if marks[root] == -1:

                marks[root] = search['mark']

                count += 1

                new_root += roots[root]

            else:

                continue

            next_search.append({'root':roots[root], 'mark':root})

    searchs = next_search[:]



del marks[1]

print('Yes')

for v in list(marks.values()):

    print(v)

    
n,m=list(map(int,input().split()))

marks = {i+1:-1 for i in range(n)}

roots = {i+1:[] for i in range(n)}



for i in range(m):

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

    roots[a].append(b)

    roots[b].append(a)



searchs = [{'root':roots[1], 'mark':1}]

while searchs != []:

    next_search = []

    for search in searchs:

        for root in search['root']:

            if marks[root] == -1:

                marks[root] = search['mark']

            else:

                continue

            next_search.append({'root':roots[root], 'mark':root})

    searchs = next_search[:]



marks[1] = 'Yes'

for v in list(marks.values()):

    print(v)

    
n, m = list(map(int, input().split()))
marks = {i + 1: -1 for i in range(n)}
marks[1] = 0
roots = {i + 1: [] for i in range(n)}
count = 0
for i in range(m):
    a, b = list(map(int, input().split()))
    roots[a].append(b)
    roots[b].append(a)
before_room = 1
searchs = [{"root": roots[1], "mark": 1}]
while searchs != []:
    next_search = []
    for search in searchs:
        for root in search["root"]:
            new_root = []
            if marks[root] == -1:
                marks[root] = search["mark"]
                count += 1
                new_root += roots[root]
            else:
                continue
            next_search.append({"root": roots[root], "mark": root})
    searchs = next_search[:]
del marks[1]
print("Yes")
for v in list(marks.values()):
    print(v)

n, m = list(map(int, input().split()))
marks = {i + 1: -1 for i in range(n)}
roots = {i + 1: [] for i in range(n)}
for i in range(m):
    a, b = list(map(int, input().split()))
    roots[a].append(b)
    roots[b].append(a)
searchs = [{"root": roots[1], "mark": 1}]
while searchs != []:
    next_search = []
    for search in searchs:
        for root in search["root"]:
            if marks[root] == -1:
                marks[root] = search["mark"]
            else:
                continue
            next_search.append({"root": roots[root], "mark": root})
    searchs = next_search[:]
marks[1] = "Yes"
for v in list(marks.values()):
    print(v)

-marks[1] = 0 -count = 0 -before_room = 1 -            new_root = [] -                count += 1 -                new_root += roots[root] -del marks[1] -print("Yes") +marks[1] = "Yes"