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 = [1]
    while !q.isEmpty {
        var q_ = [Int]()
        for u in q {
            for v in graph[u] {
                guard ans[v] == -1 else { continue }
                ans[v] = u
                q_.append(v)
            }
        }
        q = q_
    }
    print("Yes")
    for i in ans[2...] {
        print(i)
    }
}

main()