from heapq import heappop, heappush



INF = 1000000

N, M = list(map(int, input().split()))

d = [INF]*(N+1)

d[1] = 0

prev = [0]*(N+1)

G = {}

for i in range(M):

  a, b = list(map(int, input().split()))

  try:

    G[a].append(b)

  except:

    G[a] = [b]

  try:

    G[b].append(a)

  except:

    G[b] = [a]



que = []

heappush(que, (0, 1))

    

while True:

  if len(que) == 0:

    break

  p = heappop(que)

  v = p[1]

  

  for u in G[v]:

    if (d[u] > d[v] + 1):

      d[u] = d[v] + 1

      heappush(que, (d[u], u))

      prev[u] = v

      

if 0 in prev[2:]:print('No')

else:

  print('Yes')

  for i in range(2, N+1):

    print((prev[i]))
from collections import deque



N,M=list(map(int,input().split()))

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

for i in range(M):

  a,b=list(map(int,input().split()))

  G[a].append(b)

  G[b].append(a)



def bfs(s):

    seen = [0]*(N+1)

    d = [0]*(N+1)

    prev = [0]*(N+1)

    todo = deque()

    seen[s]=1

    todo.append(s)

    while len(todo):

      a = todo.popleft()

      for b in G[a]:

        if seen[b] == 0:

          seen[b] = 1

          todo.append(b)

          d[b] += d[a] + 1

          prev[b] = a

    return prev

  

prev = bfs(1)



print('Yes')

print((*prev[2:]))
from heapq import heappop, heappush

INF = 1000000
N, M = list(map(int, input().split()))
d = [INF] * (N + 1)
d[1] = 0
prev = [0] * (N + 1)
G = {}
for i in range(M):
    a, b = list(map(int, input().split()))
    try:
        G[a].append(b)
    except:
        G[a] = [b]
    try:
        G[b].append(a)
    except:
        G[b] = [a]
que = []
heappush(que, (0, 1))
while True:
    if len(que) == 0:
        break
    p = heappop(que)
    v = p[1]
    for u in G[v]:
        if d[u] > d[v] + 1:
            d[u] = d[v] + 1
            heappush(que, (d[u], u))
            prev[u] = v
if 0 in prev[2:]:
    print("No")
else:
    print("Yes")
    for i in range(2, N + 1):
        print((prev[i]))

from collections import deque

N, M = list(map(int, input().split()))
G = [[] for _ in range(N + 1)]
for i in range(M):
    a, b = list(map(int, input().split()))
    G[a].append(b)
    G[b].append(a)


def bfs(s):
    seen = [0] * (N + 1)
    d = [0] * (N + 1)
    prev = [0] * (N + 1)
    todo = deque()
    seen[s] = 1
    todo.append(s)
    while len(todo):
        a = todo.popleft()
        for b in G[a]:
            if seen[b] == 0:
                seen[b] = 1
                todo.append(b)
                d[b] += d[a] + 1
                prev[b] = a
    return prev


prev = bfs(1)
print("Yes")
print((*prev[2:]))

-from heapq import heappop, heappush +from collections import deque -INF = 1000000 -d = [INF] * (N + 1) -d[1] = 0 -prev = [0] * (N + 1) -G = {} +G = [[] for _ in range(N + 1)] -    try: -        G[a].append(b) -    except: -        G[a] = [b] -    try: -        G[b].append(a) -    except: -        G[b] = [a] -que = [] -heappush(que, (0, 1)) -while True: -    if len(que) == 0: -        break -    p = heappop(que) -    v = p[1] -    for u in G[v]: -        if d[u] > d[v] + 1: -            d[u] = d[v] + 1 -            heappush(que, (d[u], u)) -            prev[u] = v -if 0 in prev[2:]: -    print("No") -else: -    print("Yes") -    for i in range(2, N + 1): -        print((prev[i])) +    G[a].append(b) +    G[b].append(a) + + +def bfs(s): +    seen = [0] * (N + 1) +    d = [0] * (N + 1) +    prev = [0] * (N + 1) +    todo = deque() +    seen[s] = 1 +    todo.append(s) +    while len(todo): +        a = todo.popleft() +        for b in G[a]: +            if seen[b] == 0: +                seen[b] = 1 +                todo.append(b) +                d[b] += d[a] + 1 +                prev[b] = a +    return prev + + +prev = bfs(1) +print("Yes") +print((*prev[2:]))