def main():

    from collections import deque

    n, m, *ab = list(map(int, open(0).read().split()))



    l = {i: [] for i in range(n + 1)}

    for i, j in zip(*[iter(ab)] * 2):

        l[i] += [j]

        l[j] += [i]



    ll = [None] * (n + 1)

    vis = [False] * (n + 1)

    que = deque([1])

    vis[1] = True

    while que:

        now = que.popleft()

        nx = l[now]

        for i in nx:

            if vis[i]:

                continue

            vis[i] = True

            ll[i] = now

            que.append(i)

    if all(vis[1:]):

        print("Yes")

        s = "\n".join(map(str, ll[2:]))

        print(s)

    else:

        print("No")





if __name__ == '__main__':

    main()

def main():

    from collections import deque

    n, m, *ab = list(map(int, open(0).read().split()))



    l = {i: [] for i in range(n + 1)}

    for i, j in zip(*[iter(ab)] * 2):

        l[i].append(j)

        l[j].append(i)



    ll = [None] * (n + 1)

    vis = [False] * (n + 1)

    que = deque([1])

    vis[1] = True

    while que:

        now = que.popleft()

        nx = l[now]

        for i in nx:

            if vis[i]:

                continue

            vis[i] = True

            ll[i] = now

            que.append(i)

    if all(vis[1:]):

        print("Yes")

        s = "\n".join(map(str, ll[2:]))

        print(s)

    else:

        print("No")





if __name__ == '__main__':

    main()

def main():
    from collections import deque

    n, m, *ab = list(map(int, open(0).read().split()))
    l = {i: [] for i in range(n + 1)}
    for i, j in zip(*[iter(ab)] * 2):
        l[i] += [j]
        l[j] += [i]
    ll = [None] * (n + 1)
    vis = [False] * (n + 1)
    que = deque([1])
    vis[1] = True
    while que:
        now = que.popleft()
        nx = l[now]
        for i in nx:
            if vis[i]:
                continue
            vis[i] = True
            ll[i] = now
            que.append(i)
    if all(vis[1:]):
        print("Yes")
        s = "\n".join(map(str, ll[2:]))
        print(s)
    else:
        print("No")


if __name__ == "__main__":
    main()

def main():
    from collections import deque

    n, m, *ab = list(map(int, open(0).read().split()))
    l = {i: [] for i in range(n + 1)}
    for i, j in zip(*[iter(ab)] * 2):
        l[i].append(j)
        l[j].append(i)
    ll = [None] * (n + 1)
    vis = [False] * (n + 1)
    que = deque([1])
    vis[1] = True
    while que:
        now = que.popleft()
        nx = l[now]
        for i in nx:
            if vis[i]:
                continue
            vis[i] = True
            ll[i] = now
            que.append(i)
    if all(vis[1:]):
        print("Yes")
        s = "\n".join(map(str, ll[2:]))
        print(s)
    else:
        print("No")


if __name__ == "__main__":
    main()

-        l[i] += [j] -        l[j] += [i] +        l[i].append(j) +        l[j].append(i)