from collections import deque


def resolve():
    n, m = map(int, input().split())
    ans = [-1 for i in range(n)]

    connections = [[] for i in range(n)]
    for i in range(m):
        a, b = map(int, input().split())
        connections[a-1].append(b-1)
        connections[b-1].append(a-1)

    # stack = []
    # connected_to_one = [*connections[0]]

    # for room in connected_to_one:
    #     ans[room] = 1

    #     connections[0].remove(room)
    #     connections[room].remove(0)

    #     stack.append(room)

    D = deque([0])
    visited = [False]*n
    visited[0] = True

    while D:
        room = D.popleft()

        for i in connections[room]:
            if visited[i]:
                continue
            visited[i] = True
            ans[i] = room + 1
            D.append(i)

    _ans = ans[1:]

    if -1 in _ans:
        print('No')
    else:
        print('Yes')
        for i in _ans:
          
resolve()