def main():

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



  r=[[]for i in range(N)]

  for i in range(M):

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

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

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



  p=[-1]*N

  q=[0]

  while q:

    i=q.pop(0)

    for j in r[i]:

      if p[j]==-1:

        p[j]=i

        q.append(j)



  print('Yes')

  for i in range(1,N):

    print((p[i]+1))



main()

from collections import deque



def main():

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



  r=[[]for i in range(N)]

  for i in range(M):

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

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

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



  p=[-1]*N

  q=deque([0])

  while q:

    i=q.popleft()

    for j in r[i]:

      if p[j]==-1:

        p[j]=i

        q.append(j)



  print('Yes')

  for i in range(1,N):

    print((p[i]+1))



main()

def main():
    N, M = list(map(int, input().split()))
    r = [[] for i in range(N)]
    for i in range(M):
        a, b = list(map(int, input().split()))
        r[a - 1].append(b - 1)
        r[b - 1].append(a - 1)
    p = [-1] * N
    q = [0]
    while q:
        i = q.pop(0)
        for j in r[i]:
            if p[j] == -1:
                p[j] = i
                q.append(j)
    print("Yes")
    for i in range(1, N):
        print((p[i] + 1))


main()

from collections import deque


def main():
    N, M = list(map(int, input().split()))
    r = [[] for i in range(N)]
    for i in range(M):
        a, b = list(map(int, input().split()))
        r[a - 1].append(b - 1)
        r[b - 1].append(a - 1)
    p = [-1] * N
    q = deque([0])
    while q:
        i = q.popleft()
        for j in r[i]:
            if p[j] == -1:
                p[j] = i
                q.append(j)
    print("Yes")
    for i in range(1, N):
        print((p[i] + 1))


main()

+from collections import deque + + -    q = [0] +    q = deque([0]) -        i = q.pop(0) +        i = q.popleft()