using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramD
    {
        private class Edge {
            public int From {get;set;}
            public int To {get;set;}
            public int Cost {get;set;}
        }

        static void Main()
        {
            int n = NextInt, m = NextInt;
            var matrix = Enumerable.Range(0, n).Select(_ => new List<int>()).ToArray();

            for (int i = 0; i < m; i++)
            {
                int a = NextInt - 1, b = NextInt - 1;
                matrix[a].Add(b);
                matrix[b].Add(a);
            }

            var pq = new PriorityQueue<Edge>((x, y) => x.Cost.CompareTo(y.Cost));
            pq.Enqueue(new Edge{From = -1, To = 0, Cost = 0});
            var distance = Enumerable.Repeat(int.MaxValue, n).ToArray();
            var froms = Enumerable.Repeat(int.MaxValue, n).ToArray();
            int visit = 0;
            while (pq.Any() && visit < n)
            {
                var tmp = pq.Dequeue();

                if (distance[tmp.To] == int.MaxValue)
                {
                    distance[tmp.To] = tmp.Cost;
                    froms[tmp.To] = tmp.From + 1;
                    visit++;

                    foreach (var next in matrix[tmp.To])
                    {
                        pq.Enqueue(new Edge{From = tmp.To, To = next, Cost = tmp.Cost + 1});
                    }
                }
            }

            if (froms.Skip(1).All(x => x != int.MaxValue))
            {
                System.Console.WriteLine("Yes");
                System.Console.WriteLine(string.Join("\n", froms.Skip(1)));
            }
            else
            {
                System.Console.WriteLine("No");
            }
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}

namespace Library
{
    public class PriorityQueue<T>
    {
        readonly List<T> _heap = new List<T>();
        readonly Comparison<T> _comparison;

        public PriorityQueue(Comparison<T> comparison)
        {
            _comparison = comparison;
        }

        public PriorityQueue() : this(Comparer<T>.Default.Compare) { }

        public PriorityQueue(IComparer<T> comparer) : this(comparer.Compare) { }

        public void Enqueue(T item)
        {
            _heap.Add(item);

            int childID = _heap.Count - 1;
            int parentID = (childID - 1) / 2;

            while (childID > 0 && _comparison(_heap[parentID], _heap[childID]) > 0)
            {
                Swap(parentID, childID);
                childID = parentID;
                parentID = (parentID - 1) / 2;
            }
        }

        public T Dequeue()
        {
            var first = _heap.First();
            _heap[0] = _heap.Last();
            _heap.RemoveAt(_heap.Count - 1);

            int parentID = 0;
            int childID = parentID * 2 + 2;
            if (childID >= _heap.Count || _comparison(_heap[childID], _heap[childID - 1]) > 0) childID--;

            while (childID < _heap.Count && _comparison(_heap[parentID], _heap[childID]) > 0)
            {
                Swap(parentID, childID);
                parentID = childID;
                childID = parentID * 2 + 2;
                if (childID >= _heap.Count || _comparison(_heap[childID], _heap[childID - 1]) > 0) childID--;
            }

            return first;
        }

        void Swap(int parent, int child)
        {
            var tmp = _heap[parent];
            _heap[parent] = _heap[child];
            _heap[child] = tmp;
        }

        public T Peek() { return _heap[0]; }
        public int Count => _heap.Count;
        public bool Any() { return _heap.Any(); }
        public List<T> Data => _heap;
    }
}


Measured memory_bytes: 63032