#include <stdio.h>
int main(void){
    int n, m, i, ii, f;
    scanf("%d %d", &n, &m);
    int a[m], b[m], flag[100001][2] = {}, ans[100001];
    for (i = 0; i < m; i++)
        scanf("%d %d", a + i, b + i);
    flag[0][0] = 1;
    flag[0][1] = 1;
    f = 1;
    while (f)
    {
        f = 0;
        for (i = 0; i < m; i++)
        {
            if (flag[a[i] - 1][0] && !flag[b[i] - 1][1])
                {
                    f = 1;
                    flag[b[i] - 1][1] = 1;
                    ans[b[i] - 1] = a[i];
                }
            if (flag[b[i] - 1][0] && !flag[a[i] - 1][1])
            {
                f = 1;
                flag[a[i] - 1][1] = 1;
                ans[a[i] - 1] = b[i];
            }
        }
        for (i = 0; i < n; i++)
            if (flag[i][1])
                flag[i][0] = 1;
    }
    for (i = 0; i < n; i++)
    {
        if (flag[i][0] == 0)
        {
            printf("No %d", i);
            return (0);
        }
    }
    printf("Yes\n");
    for (i = 1; i < n; i++)
        printf("%d\n", ans[i]);
    
    return (0);
}
