//
#include "bits/stdc++.h"

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<long,long> plong;

const double pi=M_PI;
const int INF10 = 1000000001, ID_MAX = 20;
const long long INF18 = 1e18 + 1;
const int mod = 1000000007;
//const int mod = 998244353;

struct edge
{
    edge(int i){
        to=i;
    }
    int to;
    long cost=1;
};

void sort2array(double *a, long *b, long n)
{
    for (int i = 0; i < n; i++)
    {
        b[i] = i;
    }
    sort(b, b + n, [a](long i, long j) -> bool { return a[i] < a[j]; });
}
//bを何回足せばaを超えるか(O(a/b))
int wtover(int a, int b)
{
    if (a % b > 0)
        return (a / b) + 1;
    else
        return a / b;
}
int bi_e[ID_MAX] = {0};
//2進数表示したときの最高桁(O(log n))
int bi_max(long n)
{
    int m = 0;
    for (m; (1 << m) <= n; m++)
        ;
    m = m - 1;
    return m;
}
//bi_eに二進数表示したやつを代入(O(log^2 n))
void bi_exs(long n)
{
    memset(bi_e, 0, sizeof(bi_e));
    if (n < (1 << ID_MAX))
    {
        for (int i = 0; n > 0; n = (n >> 1), i++)
            bi_e[i] = n & 1;
    }
}
//x^n mod m (nが負の時は０)(O(log n))
long myPow(long x, long n, long m)
{
    if (n < 0)
        return 0;
    if (n == 0)
        return 1;
    if (n % 2 == 0)
        return myPow(x * x % m, n / 2, m);
    else
        return x * myPow(x, n - 1, m) % m;
}
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

//分割数のmodの表生成(tof=falseで重複あり)d[i][j]=jのi分割
struct divNum
{
    vector<vector<mint>> d;
    int N, M;
    divNum(int n, int m, bool tof) : d(n + 1, vector<mint>(m + 1, 0))
    {
        N = n;
        M = m;
        if (tof)
        {
            rep(j, n + 1)
            {
                d[j][0] = 1;
            }
            rep(j, m)
            {
                d[0][j + 1] = 0;
            }
            for (int j = 1; j <= n; j++)
            {
                for (int k = 1; k <= m; k++)
                {
                    if (j > k)
                        d[j][k] = d[j - 1][k];
                    else
                        d[j][k] = d[j - 1][k] + d[j][k - j];
                }
            }
        }
        else
        {
            d[0][0] = 1;
            rep(i, n)
            {
                rep(j, m + 1)
                {
                    rep(k, m - j + 1)
                    {
                        d[i + 1][j + k] = d[i + 1][j + k] + d[i][j];
                    }
                }
            }
        }
    }
    mint operator()(int n, int m)
    {
        if (n < 0 || m < 0 || n > N || m > M)
            return 0;
        else
        {
            return d[n][m];
        }
    }
};
const int N_MAX=100001;
int n,m;
pint frag[N_MAX];
//vector<int> v[N_MAX];

/*void bfs(){
    int x=-1;
    queue<int> que;
    que.push(0);
    frag[0]=pint(1,0);
    while(que.size()){
        int now=que.front(),next;
        que.pop();
        rep(i,v[now].size()){
            if(frag[v[now].at(i)].first==-1){
                frag[v[now].at(i)]=pint(frag[now].first+1,now);
                que.push(v[now].at(i));
            }else if(v[now].at(i)==0){
                x=now;
            }
        }
    }
    if(x==-1){
        cout<<"No"<<endl;
    }else{
        stack<int> ans;
        while()
    }
}*/

int V;
vector<edge> g[N_MAX];
pint d[N_MAX];

void dijkstra(int s) {
    priority_queue<pint, vector<pint>, greater<pint> > que;
    rep(i,n){
        d[i]=pint(INF10,-1);
    }
    d[s] = pint(0,0);
    que.push(pint(0, s));

    while (!que.empty()) {
        pint p = que.top();
        que.pop();
        int v = p.second;
        if (d[v].first < p.first) continue;

        for (int i=0; i<g[v].size(); ++i) {
            edge e = g[v][i];
            if (d[e.to].first > d[v].first + e.cost) {
                d[e.to].first = d[v].first + e.cost;
                d[e.to].second=v;
                que.push(pint(d[e.to].first, e.to));
            }
        }
    }
}
int main(){
    int i,x,y;
    //入力
    cin>>n>>m;
    rep(i,m){
        cin>>x>>y;
        g[x-1].push_back(edge(y-1));
        g[y-1].push_back(edge(x-1));
    }
    //処理
    dijkstra(0);
    for(int i=1;i<n;i++){
        if(d[i].first==INF10){
            cout<<"No"<<endl;
            return 0;
        }
    }
    //出力
    cout<<"Yes"<<endl;
    for(int i=1;i<n;i++){
        cout<<d[i].second+1<<endl;
    }
}

Measured memory_bytes: 17512