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

struct Room: Equatable {
    let id: Int
    var roots = [Int]()
    var flags: Int?
}

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: [Room] = (1...N).map { Room(id: $0) }


var old = [1]
var now = [1]
while !now.isEmpty {
    for i in now {
        let rs = roots
            .compactMap { $0.other(of: i) }
            .filter { !old.contains($0) }
        old.append(contentsOf: rs)
        
        now = rs
        for j in rs {
            rooms[j-1].flags = i
        }
    }
}

if rooms[1...].allSatisfy({ $0.flags != nil }) {
    print("Yes")
    rooms[1...].forEach { print($0.flags!) }
} 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()!)
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating get {
            if let note = dictionary[argument] {
                return note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                return result
            }
        }
    }
}
