from collections import deque



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



g = [[] for _ in range(N + 1)]



for _ in range(M):

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

    g[A].append(B)

    g[B].append(A)



    #print("->", g)





def bfs(u):

    queue = deque([u])

    d = [None] * (N + 1)

    d[0] = 0

    d[u] = 0



    while queue:

        v = queue.popleft()

        for i in g[v]:

            if d[i] is None:

                #d[i] = d[v] + 1

                d[i] = v

                queue.append(i)

    

    return d



d = bfs(1)



if None in d:

    print("No")

else:

    print("Yes")

    for i in d[2:]:

        print(i)



import sys

from collections import deque





def main():

    N, M, *AB = list(map(int, sys.stdin.buffer.read().split()))

    

    g = [[] for _ in range(N + 1)]



    for A, B in zip(*[iter(AB)] * 2):

        g[A].append(B)

        g[B].append(A)



        #print("->", g)



    queue = deque([1])

    d = [None] * (N + 1)

    d[0] = 0

    d[1] = 0



    while queue:

        v = queue.popleft()

        for i in g[v]:

            if d[i] is None:

                #d[i] = d[v] + 1

                d[i] = v

                queue.append(i)



    if None in d:

        print("No")

    else:

        print("Yes")

        print(("\n".join(map(str, d[2:]))))





if __name__ == '__main__':

	main()



exit()

from collections import deque

N, M = list(map(int, input().split()))
g = [[] for _ in range(N + 1)]
for _ in range(M):
    A, B = list(map(int, input().split()))
    g[A].append(B)
    g[B].append(A)
    # print("->", g)


def bfs(u):
    queue = deque([u])
    d = [None] * (N + 1)
    d[0] = 0
    d[u] = 0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                # d[i] = d[v] + 1
                d[i] = v
                queue.append(i)
    return d


d = bfs(1)
if None in d:
    print("No")
else:
    print("Yes")
    for i in d[2:]:
        print(i)

import sys
from collections import deque


def main():
    N, M, *AB = list(map(int, sys.stdin.buffer.read().split()))
    g = [[] for _ in range(N + 1)]
    for A, B in zip(*[iter(AB)] * 2):
        g[A].append(B)
        g[B].append(A)
        # print("->", g)
    queue = deque([1])
    d = [None] * (N + 1)
    d[0] = 0
    d[1] = 0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                # d[i] = d[v] + 1
                d[i] = v
                queue.append(i)
    if None in d:
        print("No")
    else:
        print("Yes")
        print(("\n".join(map(str, d[2:]))))


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

+import sys -N, M = list(map(int, input().split())) -g = [[] for _ in range(N + 1)] -for _ in range(M): -    A, B = list(map(int, input().split())) -    g[A].append(B) -    g[B].append(A) -    # print("->", g) - -def bfs(u): -    queue = deque([u]) +def main(): +    N, M, *AB = list(map(int, sys.stdin.buffer.read().split())) +    g = [[] for _ in range(N + 1)] +    for A, B in zip(*[iter(AB)] * 2): +        g[A].append(B) +        g[B].append(A) +        # print("->", g) +    queue = deque([1]) -    d[u] = 0 +    d[1] = 0 -    return d +    if None in d: +        print("No") +    else: +        print("Yes") +        print(("\n".join(map(str, d[2:])))) -d = bfs(1) -if None in d: -    print("No") -else: -    print("Yes") -    for i in d[2:]: -        print(i) +if __name__ == "__main__": +    main() +exit()