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

import sys

sys.setrecursionlimit(10**6)

L=[set() for i in range(n)]

for i in range(m):

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

    L[a-1] |= {b}

    L[b-1] |= {a}

Y = {list(range(1, n+1))}

Z = [0]*(n-1) 

S = {1}

def f(X):

    global S, Z

    X_next = set()

    for j in X:

        R = L[j-1]-S

        S |= L[j-1]

        X_next |= R

        for k in R:

            Z[k-2] += j

    if X_next == set():

        print("Yes")

        print(('\n'.join(map(str, Z))))

    else:

        return  f(X_next)

f({1})
n, m = list(map(int, input().split()))

L=[set() for i in range(n)]

for i in range(m):

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

    L[a-1] |= {b}

    L[b-1] |= {a}

Y = {list(range(1, n+1))}

Z = [0]*(n-1) 

S = {1}

X = {1}

while len(S) != n:

    X_next = set()

    for j in X:

        R = L[j-1]-S

        S |= R

        X_next |= R

        for k in R:

            Z[k-2] += j

    X = X_next

    continue

else:

    print("Yes")

    print(('\n'.join(map(str, Z))))
n, m = list(map(int, input().split()))
import sys

sys.setrecursionlimit(10**6)
L = [set() for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    L[a - 1] |= {b}
    L[b - 1] |= {a}
Y = {list(range(1, n + 1))}
Z = [0] * (n - 1)
S = {1}


def f(X):
    global S, Z
    X_next = set()
    for j in X:
        R = L[j - 1] - S
        S |= L[j - 1]
        X_next |= R
        for k in R:
            Z[k - 2] += j
    if X_next == set():
        print("Yes")
        print(("\n".join(map(str, Z))))
    else:
        return f(X_next)


f({1})

n, m = list(map(int, input().split()))
L = [set() for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    L[a - 1] |= {b}
    L[b - 1] |= {a}
Y = {list(range(1, n + 1))}
Z = [0] * (n - 1)
S = {1}
X = {1}
while len(S) != n:
    X_next = set()
    for j in X:
        R = L[j - 1] - S
        S |= R
        X_next |= R
        for k in R:
            Z[k - 2] += j
    X = X_next
    continue
else:
    print("Yes")
    print(("\n".join(map(str, Z))))

-import sys - -sys.setrecursionlimit(10**6) - - -def f(X): -    global S, Z +X = {1} +while len(S) != n: -        S |= L[j - 1] +        S |= R -    if X_next == set(): -        print("Yes") -        print(("\n".join(map(str, Z)))) -    else: -        return f(X_next) - - -f({1}) +    X = X_next +    continue +else: +    print("Yes") +    print(("\n".join(map(str, Z))))