#include <stdio.h>
int asc(const void *a, const void *b)
{
    return *((int *)a + 2) - *((int *)b + 2);
}
int main()
{
    int n, m;
    int edge[400010][2] = {}; //[0]:辺の行き先，[1]：同じ頂点から出る次の辺の枠
    int node[100010] = {};    //各ノードから出る辺の最初の枠
    int a, b;
    int ans[100010];
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; i++)
    {
        scanf("%d %d", &a, &b);
        edge[i][0] = b;
        edge[i][1] = node[a];
        node[a] = i;
        edge[i + m][0] = a;
        edge[i + m][1] = node[b];
        node[b] = i + m;
    }
    int queue[100010] = {};
    int done[100010] = {};
    int start, end;
    int now, next, t;
    start = 0;
    end = 0;
    queue[0] = 1;
    done[1] = 1;
    while (start <= end)
    {
        now = queue[start]; //今いる部屋
        t = node[now];      //今いる部屋から出る辺の枠
        while (t != 0)
        {
            next = edge[t][0]; //nowから行ける部屋
            if (done[next] == 0)
            {
                //edge[t] 今いる部屋から出る辺
                queue[++end] = edge[t][0];
                ans[edge[t][0]] = now;
                done[next] = 1; //queueに追加済みかどうか
            }
            t = edge[t][1];
        }
        start++;
    }
    printf("Yes\n");
    for (int i = 2; i <= n; i++)
    {
        printf("%d\n", ans[i]);
    }
    return 0;
}