import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Objects;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

    static long[] dist = new long[100005];
    static int[] prev = new int[100005];
    static int[] next = new int[100005];
    static boolean[] visited = new boolean[100005];
    static ArrayList<Integer>[] g = graph(100005 + 1);

    public static void main(String[] args) throws Exception {
        long startTime = System.nanoTime();
        int t = 1;
        while (t-- > 0) {
            solve();
        }
        long endTime = System.nanoTime();
        err.println("Execution Time : +" + (endTime - startTime) / 1000000 + " ms");
        exit(0);
    }

    static void solve() {
        int N = in.nextInt();
        int M = in.nextInt();
        for (int i = 0; i < M; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            g[a].add(b);
            g[b].add(a);
        }
        BFS(N, 0);
        StringBuilder res = new StringBuilder();
        boolean found = true;
        for (int i = 1; i < N; i++) {
            if (dist[i] == Integer.MAX_VALUE) {
                found = false;
                break;
            }
            res.append(prev[i] + 1);
            res.append("\n");
        }
        if (found) {
            out.println("Yes");
            out.print(res);
        } else {
            out.println("No");
        }
    }

    static void BFS(int n, int s) {
        Queue<Integer> Q = new ArrayDeque<>();
        dist[s] = 0;
        visited[s] = true;
        Q.add(s);
        while (!Q.isEmpty()) {
            int v = Q.poll();
            for (int a : g[v]) {
                if (!visited[a]) {
                    visited[a] = true;
                    dist[a] = dist[v] + 1;
                    prev[a] = v;
                    Q.add(a);
                }
            }
        }
    }

    static void dijkstra(int n, int s) {
        TreeSet<Pair<Integer, Long>> Q = new TreeSet<>(Comparator.comparingLong(Pair::getSecond));
        Set<Integer> qs = new HashSet<>();
        dist[s] = 0;
        for (int i = 0; i < n; i++) {
            if (i != s) {
                dist[i] = Integer.MAX_VALUE;
                prev[i] = -1;
            }
            Q.add(make_pair(i, dist[i]));
            qs.add(i);
        }
        while (!Q.isEmpty()) {
            Pair<Integer, Long> u = Q.pollFirst();
            qs.remove(u.first);
            visited[u.first] = true;
            for (int a : g[u.first]) {
                if (qs.contains(a)) {
                    long temp = dist[u.first] + 1;
                    if (temp < dist[a]) {
                        Q.remove(make_pair(a, dist[a]));
                        dist[a] = temp;
                        prev[a] = u.first;
                        Q.add(make_pair(a, dist[a]));
                    }
                }
            }
        }
    }

    static <T, R> Pair<T, R> make_pair(T a, R b) {
        return new Pair<>(a, b);
    }

    static class Pair<T, R> {
        public T first;
        public R second;

        public Pair(T first, R second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public boolean equals(final Object o) {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
                return false;
            }
            final Pair<?, ?> pair = (Pair<?, ?>) o;
            return Objects.equals(first, pair.first) && Objects.equals(second, pair.second);
        }

        @Override
        public int hashCode() {
            return Objects.hash(first, second);
        }

        @Override
        public String toString() {
            return "Pair{" + "a=" + first + ", b=" + second + '}';
        }

        public T getFirst() {
            return first;
        }

        public R getSecond() {
            return second;
        }
    }

    static ArrayList<Integer>[] graph(int n) {
        ArrayList<Integer>[] g = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            g[i] = new ArrayList<>();
        }
        return g;
    }

    static void debug(Object... args) {
        for (Object a : args) {
            out.println(a);
        }
    }

    static void y() {
        out.println("YES");
    }

    static void n() {
        out.println("NO");
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] readAllInts(int n) {
            int[] p = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = in.nextInt();
            }
            return p;
        }

        public int[] readAllInts(int n, int s) {
            int[] p = new int[n + s];
            for (int i = s; i < n + s; i++) {
                p[i] = in.nextInt();
            }
            return p;
        }

        public long[] readAllLongs(int n) {
            long[] p = new long[n];
            for (int i = 0; i < n; i++) {
                p[i] = in.nextInt();
            }
            return p;
        }

        public long[] readAllLongs(int n, int s) {
            long[] p = new long[n + s];
            for (int i = s; i < n + s; i++) {
                p[i] = in.nextInt();
            }
            return p;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    static void exit(int a) {
        out.close();
        err.close();
        System.exit(a);
    }

    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static OutputStream errStream = System.err;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);
    static PrintWriter err = new PrintWriter(errStream);
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

}


Measured memory_bytes: 64716