# D - .. (Double Dots)

from collections import deque





def main():

    N, M, *AB = list(map(int, open(0).read().split()))



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

    for a, b in zip(*[iter(AB)] * 2):

        graph[a].append(b)

        graph[b].append(a)



    # bfs

    depth = [1 << 30] * (N + 1)

    depth[1] = 0

    queue = deque([(1, 0)])

    while queue:

        u, cur_depth = queue.popleft()

        next_depth = cur_depth + 1

        for v in graph[u]:

            if depth[v] > next_depth:

                depth[v] = next_depth

                queue.append((v, next_depth))



    # place signposts

    signposts = [0] * (N + 1)

    for u, cur_depth in enumerate(depth[2:], 2):

        prev_depth = cur_depth - 1

        for v in graph[u]:

            if depth[v] == prev_depth:

                signposts[u] = v

                break



    print("Yes")

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





if __name__ == "__main__":

    main()

# D - .. (Double Dots)

from collections import deque





def main():

    N, M, *AB = list(map(int, open(0).read().split()))



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

    for a, b in zip(*[iter(AB)] * 2):

        graph[a].append(b)

        graph[b].append(a)



    # bfs

    queue = deque([1])

    signposts = [0] * (N + 1)

    signposts[1] = 1

    while queue:

        u = queue.popleft()

        for v in graph[u]:

            if not signposts[v]:

                signposts[v] = u

                queue.append(v)



    if all(signposts[2:]):

        print("Yes")

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

    else:

        print("No")





if __name__ == "__main__":

    main()

# D - .. (Double Dots)
from collections import deque


def main():
    N, M, *AB = list(map(int, open(0).read().split()))
    graph = [[] for _ in range(N + 1)]
    for a, b in zip(*[iter(AB)] * 2):
        graph[a].append(b)
        graph[b].append(a)
    # bfs
    depth = [1 << 30] * (N + 1)
    depth[1] = 0
    queue = deque([(1, 0)])
    while queue:
        u, cur_depth = queue.popleft()
        next_depth = cur_depth + 1
        for v in graph[u]:
            if depth[v] > next_depth:
                depth[v] = next_depth
                queue.append((v, next_depth))
    # place signposts
    signposts = [0] * (N + 1)
    for u, cur_depth in enumerate(depth[2:], 2):
        prev_depth = cur_depth - 1
        for v in graph[u]:
            if depth[v] == prev_depth:
                signposts[u] = v
                break
    print("Yes")
    print(("\n".join(map(str, signposts[2:]))))


if __name__ == "__main__":
    main()

# D - .. (Double Dots)
from collections import deque


def main():
    N, M, *AB = list(map(int, open(0).read().split()))
    graph = [[] for _ in range(N + 1)]
    for a, b in zip(*[iter(AB)] * 2):
        graph[a].append(b)
        graph[b].append(a)
    # bfs
    queue = deque([1])
    signposts = [0] * (N + 1)
    signposts[1] = 1
    while queue:
        u = queue.popleft()
        for v in graph[u]:
            if not signposts[v]:
                signposts[v] = u
                queue.append(v)
    if all(signposts[2:]):
        print("Yes")
        print(("\n".join(map(str, signposts[2:]))))
    else:
        print("No")


if __name__ == "__main__":
    main()

-    depth = [1 << 30] * (N + 1) -    depth[1] = 0 -    queue = deque([(1, 0)]) +    queue = deque([1]) +    signposts = [0] * (N + 1) +    signposts[1] = 1 -        u, cur_depth = queue.popleft() -        next_depth = cur_depth + 1 +        u = queue.popleft() -            if depth[v] > next_depth: -                depth[v] = next_depth -                queue.append((v, next_depth)) -    # place signposts -    signposts = [0] * (N + 1) -    for u, cur_depth in enumerate(depth[2:], 2): -        prev_depth = cur_depth - 1 -        for v in graph[u]: -            if depth[v] == prev_depth: -                signposts[u] = v -                break -    print("Yes") -    print(("\n".join(map(str, signposts[2:])))) +            if not signposts[v]: +                signposts[v] = u +                queue.append(v) +    if all(signposts[2:]): +        print("Yes") +        print(("\n".join(map(str, signposts[2:])))) +    else: +        print("No")