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

class Program
{
  static void Main(string[] args)
  {
        int[] arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var N = arr[0];
        var M = arr[1];
        var G = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            G[i] = new List<int>();
        }
        for (int i = 0; i < M; i++)
        {
            int[] arrTwo = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var a = arrTwo[0];
            var b = arrTwo[1];
            a--; b--;
            G[a].Add(b);
            G[b].Add(a);
        }
        var q = new Queue<(int, int, int)>();
        var visited = new bool[N];
        visited[0] = true;
        var michishirube = new int[N];
        q.Enqueue((0, -1, 0));
        while (q.Count > 0)
        {
            var t = q.Dequeue();
            var now = t.Item1;
            var prev = t.Item2;
            var d = t.Item3;
            foreach (var next in G[now])
            {
                if (visited[next]) continue;
                visited[next] = true;
                michishirube[next] = now;
                q.Enqueue((next, now, d + 1));
            }
        }
        Console.WriteLine("Yes");
        for (int i = 1; i < N; i++)
        {
            Console.WriteLine(michishirube[i] + 1);
        }


    }

   

}

