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

namespace contest_Csharp
{
    class Program
    {
        static long power(long a, long b, long modulo)
        {
            long result = 1;
            long buff = a;
            for (long i = 1; i <= b; i *= 2)
            {
                result = result * ((b / i % (2) == 1) ? buff : 1) % modulo;
                buff = (buff * buff) % modulo;
            }
            return result % modulo;
        }
        
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var vals = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();
            var N = vals[0];
            var M = vals[1];

            List<int>[] path = new List<int>[N + 1];
            for (int i = 0; i < N+1; i++)
            {
                path[i] = new List<int>();
            }
            for (int i = 0; i < M; i++)
            {
                var ps = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();
                var A = ps[0];
                var B = ps[1];
                path[A].Add(B);
                path[B].Add(A);

            }
            long[] cost = new long[N + 1];
            for (int i = 0; i < N+1; i++)
            {
                cost[i] = int.MaxValue;
            }
            cost[1] = 0;
            bool[] kakutei = new bool[N + 1];
            kakutei[1] = true;
            PriorityQueue<(int cost, int pos,int parent)> pq = new PriorityQueue<(int cost, int pos,int parent)>();


            int now = 1;
            int[] ans = new int[N + 1];
            int cnt = 1;
            do
            {
                foreach (var to in path[now])
                {
                    pq.Enqueue(((int)cost[now] + 1, to,now));
                }
                while (kakutei[pq.Peek().pos] || pq.Peek().cost>cost[pq.Peek().pos])
                {
                    pq.Dequeue();
                }
                

                var old = now;
                if (pq.Count() == 0)
                {                    
                    break;
                }
                var Q = pq.Dequeue();
                now = Q.pos;
                cost[now] = Q.cost;
                ans[now] = Q.parent;
                kakutei[now] = true;
                cnt++;
            } while (cnt<2*N);
            
            Console.WriteLine("Yes");
            for (int i = 2; i < N+1; i++)
            {
                Console.WriteLine(ans[i]);
            }
            Console.Out.Flush();
        }



    }
    class PriorityQueue<T> where T : IComparable<T>
    {
        private List<T> heap = new List<T>();
        private int lastindex = -1;
        private void swap(int n, int m)
        {
            T wait = heap[n];
            heap[n] = heap[m];
            heap[m] = wait;
        }
        public int Count()
        {
            return lastindex + 1;
        }
        public void Enqueue(T data)
        {
            int p;
            if (lastindex + 1 < heap.Count())
            {
                heap[lastindex + 1] = data;
            }
            else
            {
                heap.Add(data);
            }
            lastindex++;
            p = lastindex;

            while (true)
            {
                if (p > 0 && heap[p].CompareTo(heap[(p - 1) / 2]) <= -1)
                {
                    swap(p, (p - 1) / 2);
                    p = (p - 1) / 2;
                }
                else
                {
                    break;
                }
            }
        }
        public T Peek()
        {
            return heap[0];
        }
        public T Dequeue()
        {
            T result = Peek();
            heap[0] = default(T);
            swap(0, lastindex);
            lastindex--;
            int p = 0;
            while (true)
            {
                int np;
                if (2 * p + 1 > lastindex)
                {
                    break;
                }
                else
                {
                    np = ((2 * p + 1 == lastindex) || heap[2 * p + 1].CompareTo(heap[2 * p + 2]) <= -1)
                        ? (2 * p + 1) : (2 * p + 2);
                }
                if (heap[p].CompareTo(heap[np]) >= 1)
                {
                    swap(p, np);
                    p = np;
                }
                else
                {
                    break;
                }
            }

            return result;
        }





    }
}


Measured memory_bytes: 64276