import sys

from collections import deque



readline = sys.stdin.readline

readall = sys.stdin.read

ns = lambda: readline().rstrip()

ni = lambda: int(readline().rstrip())

nm = lambda: map(int, readline().split())

nl = lambda: list(map(int, readline().split()))

prn = lambda x: print(*x, sep='\n')



n, m = nm()

G = [list() for _ in range(n)]

for _ in range(m):

    u, v = nm()

    u -= 1; v -= 1

    G[u].append(v)

    G[v].append(u)



michi = [0]*n

dist = [n]*n

dist[0] = 0



q = deque()

q.append(0)

while q:

    v = q.popleft()

    for x in G[v]:

        if dist[x] > dist[v] + 1:

            dist[x] = dist[v] + 1

            michi[x] = v + 1

            q.append(x)

print('Yes')

prn(michi[1:])

import sys

from collections import deque



readline = sys.stdin.buffer.readline

ni = lambda: int(readline().rstrip())

nm = lambda: map(int, readline().split())

nl = lambda: list(map(int, readline().split()))



def bfs(G, s, t=None):

    """

    G[v] = [x1, x2,...]

    """

    dist = [-1] * len(G)

    dist[s] = 0

    par = [-1] * len(G)

    q = deque([s])

    while q:

        v = q.popleft()

        for x in G[v]:

            if dist[x] < 0 or dist[x] > dist[v] + 1:

                par[x] = v + 1

                dist[x] = dist[v] + 1

                q.append(x)

    return par





def solve():

    n, m = nm()

    G = [list() for _ in range(n)]

    for _ in range(m):

        u, v = nm()

        u -= 1; v -= 1

        G[u].append(v)

        G[v].append(u)

    par = bfs(G, 0)

    print('Yes')

    print(*par[1:], sep='\n')

    return



solve()



# T = ni()

# for _ in range(T):

#     solve()

import sys
from collections import deque

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep="\n")
n, m = nm()
G = [list() for _ in range(n)]
for _ in range(m):
    u, v = nm()
    u -= 1
    v -= 1
    G[u].append(v)
    G[v].append(u)
michi = [0] * n
dist = [n] * n
dist[0] = 0
q = deque()
q.append(0)
while q:
    v = q.popleft()
    for x in G[v]:
        if dist[x] > dist[v] + 1:
            dist[x] = dist[v] + 1
            michi[x] = v + 1
            q.append(x)
print("Yes")
prn(michi[1:])

import sys
from collections import deque

readline = sys.stdin.buffer.readline
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))


def bfs(G, s, t=None):
    """
    G[v] = [x1, x2,...]
    """
    dist = [-1] * len(G)
    dist[s] = 0
    par = [-1] * len(G)
    q = deque([s])
    while q:
        v = q.popleft()
        for x in G[v]:
            if dist[x] < 0 or dist[x] > dist[v] + 1:
                par[x] = v + 1
                dist[x] = dist[v] + 1
                q.append(x)
    return par


def solve():
    n, m = nm()
    G = [list() for _ in range(n)]
    for _ in range(m):
        u, v = nm()
        u -= 1
        v -= 1
        G[u].append(v)
        G[v].append(u)
    par = bfs(G, 0)
    print("Yes")
    print(*par[1:], sep="\n")
    return


solve()
# T = ni()
# for _ in range(T):
#     solve()

-readline = sys.stdin.readline -readall = sys.stdin.read -ns = lambda: readline().rstrip() +readline = sys.stdin.buffer.readline -prn = lambda x: print(*x, sep="\n") -n, m = nm() -G = [list() for _ in range(n)] -for _ in range(m): -    u, v = nm() -    u -= 1 -    v -= 1 -    G[u].append(v) -    G[v].append(u) -michi = [0] * n -dist = [n] * n -dist[0] = 0 -q = deque() -q.append(0) -while q: -    v = q.popleft() -    for x in G[v]: -        if dist[x] > dist[v] + 1: -            dist[x] = dist[v] + 1 -            michi[x] = v + 1 -            q.append(x) -print("Yes") -prn(michi[1:]) + + +def bfs(G, s, t=None): +    """ +    G[v] = [x1, x2,...] +    """ +    dist = [-1] * len(G) +    dist[s] = 0 +    par = [-1] * len(G) +    q = deque([s]) +    while q: +        v = q.popleft() +        for x in G[v]: +            if dist[x] < 0 or dist[x] > dist[v] + 1: +                par[x] = v + 1 +                dist[x] = dist[v] + 1 +                q.append(x) +    return par + + +def solve(): +    n, m = nm() +    G = [list() for _ in range(n)] +    for _ in range(m): +        u, v = nm() +        u -= 1 +        v -= 1 +        G[u].append(v) +        G[v].append(u) +    par = bfs(G, 0) +    print("Yes") +    print(*par[1:], sep="\n") +    return + + +solve() +# T = ni() +# for _ in range(T): +#     solve()