"use strict";
    
class Graph {
    constructor(n) {
        this.connectedList = {};
        this.from = [...Array(n)].fill(Infinity);
    }
    
    addVertex(vertex) {
        this.connectedList[vertex] = []
    }
    
    addEdge(v1, v2) {
        this.connectedList[v1].push(v2);
        this.connectedList[v2].push(v1);
    }
    
    removeEdge(vertex1, vertex2) {
        this.connectedList[vertex1] = this.connectedList[vertex1].filter(
            v => v !== vertex2
        );
        
        this.connectedList[vertex2] = this.connectedList[vertex2].filter(
            v => v !== vertex1
        );
    }
    
    removeVertex(vertex) {
        while (this.adjacencyList[vertex].length) {
            const adjacentVertex = this.adjacencyList[vertex].pop();
            this.removeEdge(vertex, adjacentVertex);
        }
        
        delete this.adjacencyList[vertex];
    }

    dfs(start) {
      //ノードを格納するスタック
      const stack = [start];
      //訪れた順番を格納
      const result = [];
      //訪れたフラグ
      const visited = {};
      //現在のノード
      let currentVertex;
      //訪問済みフラグを立てる
      visited[start] = true;
      
      while (stack.length) {
        // stackの最後尾を取得&削除
        currentVertex = stack.pop();

        // resuktに現在の頂点を追加
        result.push(currentVertex);

        // console.log("現在地点は" + currentVertex);
        // console.log("探索済みなのは:" + result);

        // 繋がっている頂点を探索して訪問済みにする
        // そして、stackにその頂点を追加
        this.connectedList[currentVertex].forEach(neighbor => {
          if (!visited[neighbor]) {
            visited[neighbor] = true;
            // console.log(neighbor + "は探索していないのでstackに追加")
            stack.push(neighbor);
          } else {
            // console.log(neighbor + "は探索済みなので何もしない")
          }
        });

        //  console.log("stack:" + stack);
        //  console.log("---------")
      }
      return result;
    }

    bfs(start) {
      // これから探索する予定のものの配列
      const queue = [start];

      // 訪問順番の結果
      const result = [];

      // 探索済みであるか
      const visited = {};
      let cost = 0;

      let currentVertex;
      visited[start] = true;

      while (queue.length) {
        // 先頭から取り出す
        currentVertex = queue.shift();

        // 現在地点を探索済みに
        result.push(currentVertex);
        // console.log("今の地点:" + currentVertex);
 
        let cnt = 0;

        this.connectedList[currentVertex].forEach(neighbor => {
          if (!visited[neighbor]) {
            visited[neighbor] = true;
            
            // console.log("v:" + currentVertex);
            // console.log("from:" + from)
            this.from[neighbor] = currentVertex;
            queue.push(neighbor);
          }
        });
        // console.log("from:" + this.from);
        // console.log("-----")
      }
      return result;
    }

}

// graph.addVertex(1)
// graph.addVertex(2)
// graph.addVertex(3)
// graph.addVertex(4)
// graph.addVertex(5)
// graph.addVertex(6)
// graph.addVertex(7)

// graph.addEdge(1, 2)
// graph.addEdge(1, 3)
// graph.addEdge(2, 4)
// graph.addEdge(4, 6)
// graph.addEdge(3, 6)
// graph.addEdge(4, 6)
// graph.addEdge(4, 5)
// graph.addEdge(5, 7)

// console.log(graph.dfs(1))
// console.log(graph.bfs(1))



const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);

    const AB = arg.slice(1, M + 1).map(n=>n.split(" ").map(l=>parseInt(l-1)));
    const graph = new Graph(N);
    
    for(let i=0; i<M; i++) {
        graph.addVertex(i);
    }
    
    for(let i=0; i<M; i++) {
        const A = AB[i][0];
        const B = AB[i][1];
        
        graph.addEdge(A, B);
    }
    
    graph.bfs(0);
    // console.log(graph.costs)
 
    console.log("Yes");
    
    for(let i=1; i<N; i++) {
        console.log(graph.from[i] + 1);
    }
    
    // console.log(JSON.stringify(graph.connectedList))
 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));