def LI():return list(map(int,input().split()))

def yes():print("Yes")

def no():print("No")

from collections import deque

def main():

  n,m=LI()

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

  for i in range(m):

    a,b=LI()

    edge[a-1]+=b-1,

    edge[b-1]+=a-1,    

  dq=deque([0])

  ans=[-1]*n

  while dq:

    g=dq.popleft()

    for i in edge[g]:

      if ans[i]==-1:

        ans[i]=g+1

        dq.append(i)

  yes()

  print((*ans[1:]))

main()

  
from collections import deque

def main():

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

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

  for _ in range(m):

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

    a-=1

    b-=1

    e[a].append(b)

    e[b].append(a)

  ans=[-1]*n

  dq=deque([0])

  while dq:

    g=dq.popleft()

    for v in e[g]:

      if ans[v]==-1:

        ans[v]=g+1

        dq.append(v)

  ans[0]="Yes"

  print((*ans))

main()  

def LI():
    return list(map(int, input().split()))


def yes():
    print("Yes")


def no():
    print("No")


from collections import deque


def main():
    n, m = LI()
    edge = [[] for i in range(n)]
    for i in range(m):
        a, b = LI()
        edge[a - 1] += (b - 1,)
        edge[b - 1] += (a - 1,)
    dq = deque([0])
    ans = [-1] * n
    while dq:
        g = dq.popleft()
        for i in edge[g]:
            if ans[i] == -1:
                ans[i] = g + 1
                dq.append(i)
    yes()
    print((*ans[1:]))


main()

from collections import deque


def main():
    n, m = list(map(int, input().split()))
    e = [[] for _ in range(n)]
    for _ in range(m):
        a, b = list(map(int, input().split()))
        a -= 1
        b -= 1
        e[a].append(b)
        e[b].append(a)
    ans = [-1] * n
    dq = deque([0])
    while dq:
        g = dq.popleft()
        for v in e[g]:
            if ans[v] == -1:
                ans[v] = g + 1
                dq.append(v)
    ans[0] = "Yes"
    print((*ans))


main()

-def LI(): -    return list(map(int, input().split())) - - -def yes(): -    print("Yes") - - -def no(): -    print("No") - - -    n, m = LI() -    edge = [[] for i in range(n)] -    for i in range(m): -        a, b = LI() -        edge[a - 1] += (b - 1,) -        edge[b - 1] += (a - 1,) +    n, m = list(map(int, input().split())) +    e = [[] for _ in range(n)] +    for _ in range(m): +        a, b = list(map(int, input().split())) +        a -= 1 +        b -= 1 +        e[a].append(b) +        e[b].append(a) +    ans = [-1] * n -    ans = [-1] * n -        for i in edge[g]: -            if ans[i] == -1: -                ans[i] = g + 1 -                dq.append(i) -    yes() -    print((*ans[1:])) +        for v in e[g]: +            if ans[v] == -1: +                ans[v] = g + 1 +                dq.append(v) +    ans[0] = "Yes" +    print((*ans))