using System;
using System.Collections.Generic;
using System.Linq;

namespace x
{
    class Program
    {
        static void Main(string[] args)
        {
            (var vCount, var edgeCount) = IOUtils.Read2Ints();

            var edges = IOUtils.ReadIntLines(edgeCount);

            var graph = new Dijkstra(vCount, false);
            foreach (var edge in edges)
            {
                graph.AddEdge(edge[0], edge[1], 1);
            }
            graph.Calc(1, null);

            System.Console.WriteLine("Yes");
            for (int i = 2; i <= vCount; i++)
            {
                System.Console.WriteLine(graph.GetPreVertex(i).Value);
            }
        }
    }


    /// <summary>
    /// ダイクストラ法で最短経路を計算
    /// </summary>
    class Dijkstra
    {
        readonly int vertexCount;
        readonly bool hasDirection;
        readonly IReadOnlyDictionary<int, Node> nodeDic;

        public struct Edge
        {
            public readonly int dest;
            public readonly int weight;

            public Edge(int dest, int weight)
            {
                this.dest = dest;
                this.weight = weight;
            }
        }

        class Node
        {
            public int V { get; }
            private readonly Dictionary<int, Edge> nextDic = new Dictionary<int, Edge>();

            public Node(int v)
            {
                this.V = v;
            }

            public bool HasNext(int v)
            {
                return this.nextDic.ContainsKey(v);
            }
            public void AddNext(int v, int weight)
            {
                if (v == this.V) throw new ArgumentException("ループには対応していません");
                this.nextDic[v] = new Edge(v, weight);
            }
            public IReadOnlyCollection<Edge> AllNexts()
            {
                return this.nextDic.Values;
            }
            public bool RemoveNext(int v)
            {
                return this.nextDic.Remove(v);
            }
            public int? TryGetWeight(int v)
            {
                Edge res;
                return this.nextDic.TryGetValue(v, out res) ? res.weight : (int?)null;
            }

            public int? CurrentWeight { get; private set; }
            public int? CurrentPreVertex { get; private set; }
            //public bool IsCommitted { get; private set; }
            //public void Commit()
            //{
            //    this.IsCommitted = true;
            //}

            public bool TryUpdateWeight(int weight, int? pre)
            {
//                if (this.IsCommitted) return false;
                if (CurrentWeight == null || weight < CurrentWeight.Value)
                {
                    this.CurrentPreVertex = pre;
                    this.CurrentWeight = weight;
                    return true;
                }
                return false;
            }

        }

        public Dijkstra(int vertexCount, bool hasDirection)
        {
            this.vertexCount = vertexCount;
            this.hasDirection = hasDirection;

            this.nodeDic = Enumerable.Range(1, vertexCount)
                                .ToDictionary(v => v, v => new Node(v));
        }
        public void AddEdge(int v1, int v2, int weight)
        {
            if (weight < 0) throw new ArgumentOutOfRangeException(nameof(weight));
            this.nodeDic[v1].AddNext(v2, weight);
            if (!this.hasDirection)
            {
                this.nodeDic[v2].AddNext(v1, weight);
            }
        }
        public bool RemoveEdge(int v1, int v2)
        {
            if (!this.nodeDic[v1].RemoveNext(v2)) return false;
            if (!this.hasDirection)
            {
                if (!this.nodeDic[v2].RemoveNext(v1))
                {
                    throw new InvalidProgramException("invalid state " + v1 + "," + v2);
                }
            }
            return true;
        }

        public void Calc(int start, int? goal)
        {
            var queue = new PriorityQueue<Node>(vertexCount, n => (n.CurrentWeight ?? 0) * -1);
            this.nodeDic[start].TryUpdateWeight(0, null);
            queue.Enqueue(this.nodeDic[start]);

            while (queue.Count > 0)
            {
                var pre = queue.Dequeue();
//                pre.Commit();
                if (goal != null && pre.V == goal) break;

                foreach (var edge in pre.AllNexts())
                {
                    var newWeight = pre.CurrentWeight.Value + edge.weight;
                    var nextNode = this.nodeDic[edge.dest];

                    if (nextNode.TryUpdateWeight(newWeight, pre.V))
                    {
                        queue.Enqueue(this.nodeDic[edge.dest]);
                    }
                }
            }
        }

        public int? GetPreVertex(int v)
        {
            return this.nodeDic[v].CurrentPreVertex;
        }
    }

    class PriorityQueue<T>
    {
        readonly T[] array;
        readonly Func<T, int> valueSelector;
        public int Count { get; private set; }


        public PriorityQueue(int capacity, Func<T, int> valueSelector)
        {
            this.array = new T[capacity];
            this.valueSelector = valueSelector;
        }

        public void Enqueue(T item)
        {
            this.array[this.Count] = item;
            this.Count += 1;
            this.UpHeap();
        }

        public T Dequeue()
        {
            // 先頭要素を末尾にして再構成
            this.Swap(0, this.Count - 1);
            this.Count -= 1;
            this.DownHeap();

            return this.array[this.Count];
        }


        private void UpHeap()
        {
            var n = this.Count - 1;
            while (n != 0)
            {
                // 親要素の座標
                var parent = (n - 1) / 2;

                if (this.valueSelector(this.array[n]) > this.valueSelector(this.array[parent]))
                {
                    this.Swap(n, parent);
                    n = parent;
                }
                else
                {
                    break;
                }
            }
        }

        private void DownHeap()
        {
            var parent = 0;
            while (true)
            {
                var child = 2 * parent + 1;
                if (child > this.Count - 1) break;

                if (child < this.Count - 1 && this.valueSelector(this.array[child]) < this.valueSelector(this.array[child + 1]))
                {
                    // 左より右の子のほうが大きい値の場合、右を入れ替え対象にする
                    child += 1;
                }

                if (this.valueSelector(this.array[parent]) < this.valueSelector(this.array[child]))
                {
                    this.Swap(parent, child);
                    parent = child;
                }
                else
                {
                    break;
                }
            }
        }

        private void Swap(int a, int b)
        {
            var tmp = this.array[a];
            this.array[a] = this.array[b];
            this.array[b] = tmp;
        }
    }
    
    static class IOUtils
    {
        public static (int a, int b) Read2Ints()
        {
            var vals = ReadInts();
            return (vals[0], vals[1]);
        }
        public static (int a, int b, int c) Read3Ints()
        {
            var vals = ReadInts();
            return (vals[0], vals[1], vals[2]);
        }
        public static IEnumerable<int[]> ReadIntLines(int count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return ReadInts();
            }
        }
        public static IEnumerable<long[]> ReadLongLines(int count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return ReadLongs();
            }
        }
        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        public static ulong ReadUlong()
        {
            return ulong.Parse(Console.ReadLine());
        }
        public static int[] ReadInts()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
        public static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


Measured memory_bytes: 89236