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)



    queue = deque([1])

    d = [0] * (N + 1)

    d[0] = 1

    d[1] = 1



    while queue:

        v = queue.popleft()

        for i in g[v]:

            if d[i] == 0:

                d[i] = v

                queue.append(i)



    if all(d):

        print("Yes")

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

    else:

        print("No")





if __name__ == '__main__':

	main()



exit()

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)



    queue = deque([1])

    d = [0] * (N + 1)

    d[0] = 1

    d[1] = 1



    while queue:

        v = queue.popleft()

        for i in g[v]:

            if not d[i]:

                d[i] = v

                queue.append(i)



    if all(d):

        print("Yes")

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

    else:

        print("No")





if __name__ == '__main__':

	main()



exit()

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)
    queue = deque([1])
    d = [0] * (N + 1)
    d[0] = 1
    d[1] = 1
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] == 0:
                d[i] = v
                queue.append(i)
    if all(d):
        print("Yes")
        print(("\n".join(map(str, d[2:]))))
    else:
        print("No")


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

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)
    queue = deque([1])
    d = [0] * (N + 1)
    d[0] = 1
    d[1] = 1
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if not d[i]:
                d[i] = v
                queue.append(i)
    if all(d):
        print("Yes")
        print(("\n".join(map(str, d[2:]))))
    else:
        print("No")


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

-            if d[i] == 0: +            if not d[i]: