let (N, M) = readInts().mapToTuple()


struct Root: Equatable {
    let a, b: Int
    
    func other(of id: Int) -> Int? {
        if a == id { return b }
        if b == id { return a }
        return nil
    }
}

var roots: [Root] = (1...M).map { i in
    let (a, b) = readInts().mapToTuple()
    return Root(a: a, b: b)
}

var rooms = Array(repeating: Optional<Int>.none, count: N)

rooms[0] = 0
var old: Set<Int> = [1]
var now = [1]
while !now.isEmpty {
    for i in now {
        let rs = roots
            .compactMap { $0.other(of: i) }
            .filter { !old.contains($0) }
//        print(rs)
        old.formUnion(rs)
        now = rs
        for j in rs {
            rooms[j-1] = i
        }
    }
}

//print(rooms)
if rooms.allSatisfy({ $0 != nil }) {
    print("Yes")
    rooms[1...].forEach { print($0!) }
} else {
    print("No")
}



// MARK: -----------------------------------------------------------------------


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

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
    
    subscript(gen: Index) -> Element {
        _modify { yield &self[index(gen, offsetBy: -1)] }
        _read   { yield self[index(gen, offsetBy: -1)] }
    }
}