using CompLib.Util;
using System;
using System.Collections.Generic;
using System.Text;

public class Program
{
    int N;
    int M;
    List<int>[] E;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        M = sc.NextInt();
        E = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            E[i] = new List<int>();
        }
        for (int i = 0; i < M; i++)
        {
            int a = sc.NextInt() - 1;
            int b = sc.NextInt() - 1;
            E[a].Add(b);
            E[b].Add(a);
        }
        int[] ans = new int[N];
        for (int i = 0; i < N; i++)
        {
            ans[i] = int.MaxValue;
        }
        ans[0] = 0;
        var q = new Queue<int>();
        q.Enqueue(0);
        while (q.Count > 0)
        {
            var d = q.Dequeue();
            foreach (int to in E[d])
            {
                if (ans[to] != int.MaxValue) continue;
                ans[to] = d;
                q.Enqueue(to);
            }
        }

        bool f = true;
        var sb = new StringBuilder();
        for (int i = 1; i < N; i++)
        {
            if (ans[i] == int.MaxValue) {
                f = false;
                break;
            }
            sb.AppendLine((ans[i] + 1).ToString());
        }
        if (f)
        {
            Console.WriteLine("Yes");
            Console.Write(sb);
        }
        else
        {
            Console.WriteLine("No");
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}
