from collections import deque



def main():

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

    to = [[] for _ in range(n+1)]

    ans = [None]*(n+1)

    for _ in range(m):

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

        to[a].append(b)

        to[b].append(a)

    q = deque([1])

    while q:

        p = q.pop()

        children = to[p]

        for child in children:

            if ans[child] is None:

                ans[child] = p

                q.appendleft(child)

    print("Yes")

    print(("\n".join(list(map(str, ans[2:])))))

    



if __name__ == "__main__":

    main()
from collections import deque



def main():

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

    to = [[] for _ in range(n+1)]

    for _ in range(m):

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

        to[a].append(b)

        to[b].append(a)

    q = deque([1])

    ans = [None]*(n+1)

    while q:

        p = q.pop()

        for child in to[p]:

            if ans[child] is None:

                ans[child] = p

                q.appendleft(child)

    print("Yes")

    print(("\n".join(list(map(str, ans[2:])))))

    

    



if __name__ == "__main__":

    main()
from collections import deque


def main():
    n, m = list(map(int, input().split()))
    to = [[] for _ in range(n + 1)]
    ans = [None] * (n + 1)
    for _ in range(m):
        a, b = list(map(int, input().split()))
        to[a].append(b)
        to[b].append(a)
    q = deque([1])
    while q:
        p = q.pop()
        children = to[p]
        for child in children:
            if ans[child] is None:
                ans[child] = p
                q.appendleft(child)
    print("Yes")
    print(("\n".join(list(map(str, ans[2:])))))


if __name__ == "__main__":
    main()

from collections import deque


def main():
    n, m = list(map(int, input().split()))
    to = [[] for _ in range(n + 1)]
    for _ in range(m):
        a, b = list(map(int, input().split()))
        to[a].append(b)
        to[b].append(a)
    q = deque([1])
    ans = [None] * (n + 1)
    while q:
        p = q.pop()
        for child in to[p]:
            if ans[child] is None:
                ans[child] = p
                q.appendleft(child)
    print("Yes")
    print(("\n".join(list(map(str, ans[2:])))))


if __name__ == "__main__":
    main()

-    ans = [None] * (n + 1) +    ans = [None] * (n + 1) -        children = to[p] -        for child in children: +        for child in to[p]: