from collections import deque

N,M,*AB=map(int,open(0).read().split())

to=[[] for _ in range(N)]

for a,b in zip(*[iter(AB)]*2):

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

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

q=deque([0])

r=[None]*N

while q:

  x=q.popleft()

  for i in to[x]:

    if r[i] is None:

      q.append(i)

      r[i]=x+1

print("Yes",*r[1:],sep="\n")

from collections import deque

def main():

	N,M,*AB=map(int,open(0).read().split())

	to=[[] for _ in range(N)]

	for a,b in zip(*[iter(AB)]*2):

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

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

	q=deque([0])

	r=[None]*N

	while q:

		x=q.popleft()

		for i in to[x]:

			if r[i] is None:

				q.append(i)

				r[i]=x+1

	print("Yes",*r[1:],sep="\n")

if __name__=='__main__':

	main()

from collections import deque

N, M, *AB = map(int, open(0).read().split())
to = [[] for _ in range(N)]
for a, b in zip(*[iter(AB)] * 2):
    to[a - 1].append(b - 1)
    to[b - 1].append(a - 1)
q = deque([0])
r = [None] * N
while q:
    x = q.popleft()
    for i in to[x]:
        if r[i] is None:
            q.append(i)
            r[i] = x + 1
print("Yes", *r[1:], sep="\n")

from collections import deque


def main():
    N, M, *AB = map(int, open(0).read().split())
    to = [[] for _ in range(N)]
    for a, b in zip(*[iter(AB)] * 2):
        to[a - 1].append(b - 1)
        to[b - 1].append(a - 1)
    q = deque([0])
    r = [None] * N
    while q:
        x = q.popleft()
        for i in to[x]:
            if r[i] is None:
                q.append(i)
                r[i] = x + 1
    print("Yes", *r[1:], sep="\n")


if __name__ == "__main__":
    main()

-N, M, *AB = map(int, open(0).read().split()) -to = [[] for _ in range(N)] -for a, b in zip(*[iter(AB)] * 2): -    to[a - 1].append(b - 1) -    to[b - 1].append(a - 1) -q = deque([0]) -r = [None] * N -while q: -    x = q.popleft() -    for i in to[x]: -        if r[i] is None: -            q.append(i) -            r[i] = x + 1 -print("Yes", *r[1:], sep="\n") + +def main(): +    N, M, *AB = map(int, open(0).read().split()) +    to = [[] for _ in range(N)] +    for a, b in zip(*[iter(AB)] * 2): +        to[a - 1].append(b - 1) +        to[b - 1].append(a - 1) +    q = deque([0]) +    r = [None] * N +    while q: +        x = q.popleft() +        for i in to[x]: +            if r[i] is None: +                q.append(i) +                r[i] = x + 1 +    print("Yes", *r[1:], sep="\n") + + +if __name__ == "__main__": +    main()