import 'dart:io';

void main(List<String> args) async {
  final NM = stdin
      .readLineSync()
      .split(' ')
      .map(
        (x) => int.parse(x),
      )
      .toList();
  final N = NM[0];
  final M = NM[1];
  // N個
  final trees = List.generate(N, (i) => []);
  for (int i = 0; i < M; i++) {
    final roomPair = stdin
        .readLineSync()
        .split(' ')
        .map(
          (x) => int.parse(x),
        )
        .toList();
    if (trees[roomPair[0] - 1].indexOf(roomPair[1]) == -1) {
      trees[roomPair[0] - 1].add(roomPair[1]);
    }
    if (trees[roomPair[1] - 1].indexOf(roomPair[0]) == -1) {
      trees[roomPair[1] - 1].add(roomPair[0]);
    }
  }

  print('Yes');
  for (int i = 1; i < N; i++) {
    final target = i + 1;
    final ans = search(trees, trees[0], target, 1, 0);
    print('$ans');
  }
}

int search(List<dynamic> trees, List<dynamic> rooms, int target, int parent,
    int parentParent) {
  for (int i = 0; i < rooms.length; i++) {
    if (rooms[i] == target) {
      return parent;
    }
  }
  for (int i = 0; i < rooms.length; i++) {
    if (rooms[i] != parentParent) {
      return search(trees, trees[rooms[i] - 1], target, rooms[i], parent);
    }
  }
}
