// No sorceries shall prevail. //           
import java.util.*;
import java.io.*;
public class Main {
	//Variables
	static long mod = 1000000007;
	static long mod2 = 998244353;
	static FastReader inp= new FastReader();
	static PrintWriter out= new PrintWriter(System.out);
	public static void main(String args[]) {		    	
	   	Main g=new Main();
	   	g.main();
	   	out.close();
	}
	
	static int n=inp.nextInt();
	static int m=inp.nextInt();
	static ArrayList<Integer> list[]=new ArrayList[n+1];
	static boolean vis[]=new boolean[n+1];
	static int moves[]=new int[n+1];
	//Main
	void main() {
		
		for(int i=0;i<=n;i++) {
			list[i]=new ArrayList<Integer>();
		}
		for(int i=0;i<m;i++) {
			int x=inp.nextInt();
			int y=inp.nextInt();
			list[x].add(y);
			list[y].add(x);
		}
		dfs(1);
		for(int i=1;i<=n;i++) {
			if(!vis[i]) {
				out.println("No");
				return;
			}
		}
		out.println("Yes");
		for(int i=0;i<=n;i++) {
			moves[i]=n;
			vis[i]=false;
		}
		moves[1]=0;
		Queue<Integer> q= new LinkedList<>();
		q.add(1);
		int cur=1;
		while(!q.isEmpty()) {
			int count=q.size();
			while(count-->0) {
				int x=q.poll();
				vis[x]=true;
				for(int gg: list[x]) {
					if(moves[gg]==n) {
						moves[gg]=cur;
						q.add(gg);
					}
				}
			}
			cur++;
		}
		for(int i=2;i<=n;i++) {
			int minMoves=n,to=-1;
			for(int gg: list[i]) {
				if(moves[gg]<minMoves) {
					minMoves=moves[gg];
					to=gg;
				}
			}
			out.println(to);
		}
	}

	static void dfs(int x) {
		vis[x]=true;
		for(int gg: list[x]) {
			if(!vis[gg]) {
				dfs(gg);
			}
		}
	}
	
	
	
	
	
	
	
	
	// Classes
	static class Edge implements Comparable<Edge>{
		int l,r;
		Edge(){}
		Edge(int l,int r){
			this.l=l;
			this.r=r;
		}
		@Override
		public int compareTo(Edge e) {
			return (l-e.l)!=0?l-e.l:r-e.r;
		}
	}
	
    static class Segment implements Comparable<Segment> {
		long l, r, initialIndex;
		Segment () {}
		Segment (long l_, long r_, long d_) {
		    this.l = l_;
		    this.r = r_;
		    this.initialIndex = d_;
		}
		@Override
		public int compareTo(Segment o) {
		    return (int)((l - o.l) !=0 ? l-o.l : initialIndex - o.initialIndex);
		}
    }
    
    static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
        String next() { 
            while (st==null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
        String nextLine() { 
            String s=""; 
            try { 
                s=br.readLine(); 
            } 
            catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return s; 
        } 
    } 
    
    // Functions
	static long gcd(long a, long b) { 
		return b==0?a:gcd(b,a%b);
	}
	static int gcd(int a, int b) { 
		return b==0?a:gcd(b,a%b);
	}
	
	void reverse(long[] A,int l,int r) {
        int i=l,j=r-1;
        while(i<j) {
            long t=A[i];
            A[i]=A[j];
            A[j]=t;
            i++;j--;
        }
    }
    void reverse(int[] A,int l,int r) {
        int i=l,j=r-1;
        while(i<j) {
            int t=A[i];
            A[i]=A[j];
            A[j]=t;
            i++;j--;
        }
    }
    
    //Input Arrays
    static void input(long a[], int n) {
		for(int i=0;i<n;i++) {
			a[i]=inp.nextLong();
		}
	}
	static void input(int a[], int n) {
		for(int i=0;i<n;i++) {
			a[i]=inp.nextInt();
		}
	}	
	static void input(String s[],int n) {
		for(int i=0;i<n;i++) {
			s[i]=inp.next();
		}
	}
	static void input(int a[][], int n, int m) {
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				a[i][j]=inp.nextInt();
			}
		}
	}
	static void input(long a[][], int n, int m) {
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				a[i][j]=inp.nextLong();
			}
		}
	}
		
}


Measured memory_bytes: 78848