import Foundation


func readInt() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}


func main() {
    let line = readInt()
    let N = line[0]
    let M = line[1]

    var graph = (0...N).map { _ in [Int]() }
    for _ in (1...M) {
        let ab = readInt()
        let a = ab[0]
        let b = ab[1]
        graph[a].append(b)
        graph[b].append(a)
    }

    var ans = [Int](repeating: -1, count: N + 1)
    var q = ArraySlice<Int>()
    q.append(1)
    while let u = q.popFirst() {
        for v in graph[u] {
            guard ans[v] == -1 else { continue }
            ans[v] = u
            q.append(v)
        }
    }

    if ans[2...].contains(-1) {
        print("No")
        return
    }

    print("Yes")
    for i in ans[2...] {
        print(i)
    }

}

main()