using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            //頂点数と辺数
            var nm = IO.ReadSplitInt;

            //グラフ入力受け取り
            var graph = new List<List<int>>();
            for (int i = 0; i < nm[0]; i++)
            {
                graph.Add(new List<int>());
            }
            for (int i = 0; i < nm[1]; i++)
            {
                var ab = IO.ReadSplitInt;
                var a = ab[0] - 1;
                var b = ab[1] - 1;
                graph[a].Add(b);
                graph[b].Add(a);
            }

            //BFSのためのデータ構造
            //全頂点を「未訪問」に初期化
            var dist = Enumerable.Repeat(-1, nm[0]).ToList();
            //訪問元
            var root = Enumerable.Repeat(-1, nm[0]).ToList();
            var que = new Queue<int>();

            //初期条件(頂点0を初期ノードとする)
            dist[0] = 0;
            root[0] = -1;
            que.Enqueue(0);

            //BFS開始(キューが空になるまで探索を行う)
            while (que.Count != 0)
            {
                //キューから先頭頂点を取り出す
                int v = que.Dequeue();

                //vから辿れる頂点をすべて調べる
                foreach (var nv in graph[v])
                {
                    //すでに発見済みの頂点は探索しない
                    if (dist[nv] != -1) continue;

                    //未発見の頂点nvについて距離情報、訪問元を更新してキューに追加する
                    dist[nv] = dist[v] + 1;
                    root[nv] = v;
                    que.Enqueue(nv);
                }
            }
            //未訪問の部屋がある⇔入口までたどる橋がない
            if (dist.Where(dis => dis == -1).Count() > 0)
            {
                WriteLine("No");
            }
            else
            {
                WriteLine("Yes");
                for (int i = 1; i < root.Count; i++)
                {
                    WriteLine(root[i] + 1);
                }
            }
        }

        public class IO
        {
            #region Input
            public static string ReadString => ReadLine();
            public static int ReadInt => int.Parse(ReadLine());
            public static long ReadLong => long.Parse(ReadLine());
            public static double ReadDouble => double.Parse(ReadLine());

            public static List<string> ReadSplitString => ReadLine().Split().ToList();
            public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
            public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
            public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }

        public static long GCD(long x, long y)
        {
            #region
            if (x < y)
            {
                var tmp = x;
                x = y;
                y = tmp;
            }
            while (true)

            {
                if (x % y == 0)
                {
                    return y;
                }
                else
                {
                    var tmp = x;
                    x = y;
                    y = tmp % y;
                }
            }
            #endregion
        }

        public static long Choice2(long n)
        {
            #region
            if (n <= 1)
                return 0;
            if (n == 2)
                return 1;
            else
                return n * (n - 1) / 2;
            #endregion
        }
    }
}

Measured memory_bytes: 52704