using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        private static List<List<int>> l = new List<List<int>>();
        static void Main(string[] args)
        {
            var r1 = ReadSplit();
            var n = r1[0].Int();
            var m = r1[1].Int();
            for (int i = 0; i <= n; i++)
            {
                l.Add(new List<int>());
            }

            for (int i = 0; i < m; i++)
            {
                var r2 = ReadSplit();
                var a = r2[0].Int();
                var b = r2[1].Int();
                l[Math.Min(a, b)].Add(Math.Max(a, b));
                l[Math.Max(a, b)].Add(Math.Min(a, b));
            }

            var aa = 1;
            var INF = -1;
            var al = new int[n + 1];
            var done = new int[n + 1];
            for (int i = 0; i <= n; i++)
            {
                al[i] = INF;
            }

            al[0] = 0;
            al[1] = 1;
            done[0] = 1;
            done[1] = 1;

            var q = new List<Tuple<int, int>>();
            foreach (var item in l[1])
            {
                q.Add(new Tuple<int, int>(1, item));
            }

            while (q.Any())
            {
                var next = new List<Tuple<int, int>>();
                foreach (var item in q)
                {
                    if (done[item.Item2] == 1) continue;
                    al[item.Item2] = item.Item1;
                    done[item.Item2] = 1;
                    next.AddRange(l[item.Item2].Select(x => new Tuple<int, int>(item.Item2, x)));
                }
                q = next;
            }

            al[0] = 1000000009;
            var min = al.Min();
            if (min == -1)
            {
                WriteRead("No");
                return;
            }
            else
            {
                Write("Yes");
                for (int i = 2; i < al.Length; i++)
                {
                    Write(al[i]);
                }
            }
            Read();
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 55068