let first = readLine()!.split(separator: " ")
let N = Int(first[0])!
let M = Int(first[1])!

var graph: [[Int]] = .init(repeating: [], count: N)

for i in 0..<M {
  let line = readLine()!.split(separator: " ")
  let A = Int(line[0])!
  let B = Int(line[1])!
  graph[A-1].append(B-1)
  graph[B-1].append(A-1)
}

var anchor: [Int] = .init(repeating: -1, count: N)
var fixed = 0

var queue: [Int] = [0]

while !queue.isEmpty {
  var tmp: [Int] = []
  for top in queue {
  	for nei in graph[top] {
      if anchor[nei] == -1 {
        fixed += 1
        anchor[nei] = top
        tmp.append(nei)
      }
    }
  }
  queue = tmp
}

if fixed == N - 1 {
  print("No")
} else {
  print("Yes")
  for i in 1..<N {
    print(anchor[i] + 1)
  }
}
