func readIntTuple() -> (Int, Int) {
    let line = readLine()!.split(separator: " ").map({Int($0)!})
    return (line[0], line[1])
}

struct LinkedList<T> {
    
    var first: Node?
    var last: Node?
    
    var isEmpty: Bool {
        return first == nil
    }
    
    mutating func append(_ e: T) -> Void {
        let node = Node(e)
        if first == nil {
            first = node
        }
        if let lastElement = last {
            lastElement.next = node;
            node.prev = lastElement;
        }
        last = node
    }
    
    mutating func delete(_ node: Node) {
        if let prev = node.prev {
            prev.next = node.next
        } else {
            first = node.next
        }
        if let next = node.next {
            next.prev = node.prev
        } else {
            last = node.prev
        }
    }
    
    mutating func removeFirst() -> T? {
        guard let firstNode = first else {
            return nil
        }
        delete(firstNode)
        return firstNode.value
    }
    
    class Node {
        var value: T
        var prev: Node?
        var next: Node?
        
        init(_ value: T) {
            self.value = value
        }
    }
}

let (N, M) = readIntTuple()
var adjacent: [[Int]] = Array(repeating: [], count: N + 1)
(1...M).forEach({ _ in
    let (A, B) = readIntTuple()
    adjacent[A].append(B)
    adjacent[B].append(A)
})

var parent = Array(repeating: -1, count: N + 1)
var list = LinkedList<Int>()
list.append(1)
while !list.isEmpty {
    let room = list.removeFirst()!
    adjacent[room].forEach({
        if parent[$0] < 0 {
            parent[$0] = room
            list.append($0)
        }
    })
}

print("Yes")
(2...N).forEach({print(parent[$0])})
