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()

        a-=1;b-=1

        edge[a].append(b)

        edge[b].append(a)    

    ans=[-1]*(n)

    goal=deque([0])

    while goal:

        g=goal.popleft()

        for i in edge[g]:

            if ans[i]==-1:

                ans[i]=g+1

                goal.append(i)

    yes()

    print((*ans[1:]))

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=[[]*n for i in range(n)]

    for i in range(m):

        a,b=LI()

        a-=1;b-=1

        edge[a].append(b)

        edge[b].append(a)

    

    ans=[-1]*(n)

    goal=deque([0])

    while goal:

        g=goal.popleft()

        for i in edge[g]:

            if ans[i]==-1:

                ans[i]=g+1

                goal.append(i)

    yes()

    print((*ans[1:]))

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()
        a -= 1
        b -= 1
        edge[a].append(b)
        edge[b].append(a)
    ans = [-1] * (n)
    goal = deque([0])
    while goal:
        g = goal.popleft()
        for i in edge[g]:
            if ans[i] == -1:
                ans[i] = g + 1
                goal.append(i)
    yes()
    print((*ans[1:]))


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 = [[] * n for i in range(n)]
    for i in range(m):
        a, b = LI()
        a -= 1
        b -= 1
        edge[a].append(b)
        edge[b].append(a)
    ans = [-1] * (n)
    goal = deque([0])
    while goal:
        g = goal.popleft()
        for i in edge[g]:
            if ans[i] == -1:
                ans[i] = g + 1
                goal.append(i)
    yes()
    print((*ans[1:]))


main()

-    edge = [[] for i in range(n)] +    edge = [[] * n for i in range(n)]