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

ab = [list(map(int, input().split()))for i in range(m)]

ans = [0] * n

edge = [[]for _ in range(n)]

for a, b in ab:

    edge[a - 1].append(b - 1)

    edge[b - 1].append(a - 1)

visited = {0}

stack = [0]

for i in stack:

    for j in edge[i]:

        if j in visited:

            continue

        stack.append(j)

        visited.add(j)

        ans[j] = i + 1

print("Yes")

print((*ans[1:]))

def resolve():

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

    ab = [list(map(int, input().split()))for i in range(m)]

    ans = [0] * n

    edge = [[]for _ in range(n)]

    for a, b in ab:

        edge[a - 1].append(b - 1)

        edge[b - 1].append(a - 1)

    visited = {0}

    stack = [0]

    for i in stack:

        for j in edge[i]:

            if j in visited:

                continue

            stack.append(j)

            visited.add(j)

            ans[j] = i + 1

    print("Yes")

    print(('\n'.join(map(str, ans[1:]))))





resolve()
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]
ans = [0] * n
edge = [[] for _ in range(n)]
for a, b in ab:
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)
visited = {0}
stack = [0]
for i in stack:
    for j in edge[i]:
        if j in visited:
            continue
        stack.append(j)
        visited.add(j)
        ans[j] = i + 1
print("Yes")
print((*ans[1:]))

def resolve():
    n, m = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for i in range(m)]
    ans = [0] * n
    edge = [[] for _ in range(n)]
    for a, b in ab:
        edge[a - 1].append(b - 1)
        edge[b - 1].append(a - 1)
    visited = {0}
    stack = [0]
    for i in stack:
        for j in edge[i]:
            if j in visited:
                continue
            stack.append(j)
            visited.add(j)
            ans[j] = i + 1
    print("Yes")
    print(("\n".join(map(str, ans[1:]))))


resolve()

-n, m = list(map(int, input().split())) -ab = [list(map(int, input().split())) for i in range(m)] -ans = [0] * n -edge = [[] for _ in range(n)] -for a, b in ab: -    edge[a - 1].append(b - 1) -    edge[b - 1].append(a - 1) -visited = {0} -stack = [0] -for i in stack: -    for j in edge[i]: -        if j in visited: -            continue -        stack.append(j) -        visited.add(j) -        ans[j] = i + 1 -print("Yes") -print((*ans[1:])) +def resolve(): +    n, m = list(map(int, input().split())) +    ab = [list(map(int, input().split())) for i in range(m)] +    ans = [0] * n +    edge = [[] for _ in range(n)] +    for a, b in ab: +        edge[a - 1].append(b - 1) +        edge[b - 1].append(a - 1) +    visited = {0} +    stack = [0] +    for i in stack: +        for j in edge[i]: +            if j in visited: +                continue +            stack.append(j) +            visited.add(j) +            ans[j] = i + 1 +    print("Yes") +    print(("\n".join(map(str, ans[1:])))) + + +resolve()