using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_168_d
    {

#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            int N, M;
            ReadInt(out N, out M);
            int[] A = new int[M + 2];
            int[] B = new int[M + 2];

            Dictionary<int, APoint> points = new Dictionary<int, APoint>();
            for(int i=1;i<=N;i++)
            {
                points[i] = new APoint() { No = i };
            }

            for (int i=0;i<M;i++)
            {
                int a, b;
                ReadInt(out a, out b);
                var point_a = points[a];
                var point_b = points[b];
                point_a.Link.Add(b);
                point_b.Link.Add(a);
            }

            var solve = new Solve1();

            solve.Calc(points);

            // すべての点で 到達できているか
            if (points.Values.Max(r => r.Score) < int.MaxValue)
            {
                // 存在するならばそのような配置を  1 つ出力してください。
                Write("Yes");
                foreach(var p in points.Values.OrderBy(r => r.No).Skip(1))
                {
                    Write(p.PrevToTop.ToString());
                }
            }
            else
            {
                Write("No");
            }
        }

        class Solve1
        {
            public void Calc(Dictionary<int,APoint> points)
            {
                // ダイクストラ法で 順番に調査する
                List<int> edgeList = new List<int>();

                edgeList.Add(1);
                points[1].Score = 0;// 到達予定

                while (edgeList.Any())
                {
                    int p = edgeList[0];
                    edgeList.RemoveAt(0);
                    var point = points[p];

                    foreach (int next_p in point.Link)
                    {
                        var point_p = points[next_p];
                        int next_score = point.Score + 1;
                        if (next_score < point_p.Score)
                        {
                            // 経路書き換え
                            point_p.PrevToTop = point.No;
                            point_p.Score = next_score;
                            // 末端追加
                            edgeList.Add(point_p.No);
                        }
                    }
                }
            }
        }
        class APoint
        {
            /// <summary>
            /// １ 番目 ＝ １ 
            /// </summary>
            public int No;

            /// <summary>
            /// その場所に到達するまでのスコア
            /// </summary>
            public int Score = int.MaxValue;
            /// <summary>
            /// リンク
            /// </summary>
            public List<int> Link = new List<int>();
            /// <summary>
            /// １ 番に行くための 最適解
            /// </summary>
            public int PrevToTop;
        }

        private static void Write(string s)
        {
            Console.WriteLine(s);
        }

        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }
        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static void ReadInt(out int a, out int b)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
        }
        private static void ReadInt(out int a, out int b, out int c)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
            c = ar[2];
        }
        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            return ss;
        }
#if !TEST
    }
}
#endif

Measured memory_bytes: 70848