import 'dart:collection';
import 'dart:io';

void main(List<String> args) async {
//  Stopwatch sw = Stopwatch()..start();
  final NM = stdin
      .readLineSync()
      .split(' ')
      .map(
        (x) => int.parse(x),
      )
      .toList();
  final N = NM[0];
  final M = NM[1];
  int maxRoomNo = -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].contains(roomPair[1] - 1)) {
      trees[roomPair[0] - 1].add(roomPair[1] - 1);
    }
    if (!trees[roomPair[1] - 1].contains(roomPair[0] - 1)) {
      trees[roomPair[1] - 1].add(roomPair[0] - 1);
    }
    if (roomPair[0] - 1 > maxRoomNo) {
      maxRoomNo = roomPair[0] - 1;
    }
    if (roomPair[1] - 1 > maxRoomNo) {
      maxRoomNo = roomPair[1] - 1;
    }
  }
//  print('${sw.elapsed}');
  // 初期条件
  final dists = List.generate(maxRoomNo + 1, (i) => -1);
  dists[0] = 0;
  final queue = Queue<int>();
  queue.add(0);
  while (queue.isNotEmpty) {
    final v = queue.removeFirst();
    trees[v].forEach(
      (roomNo) {
        if (dists[roomNo] != -1) {
        } else {
          dists[roomNo] = dists[v] + 1;
          queue.add(roomNo);
        }
      },
    );
  }
//  print('${sw.elapsed}');
  print('Yes');
  for (int i = 1; i < N; i++) {
    final d = dists[i];
    print(dists.indexOf(d - 1) + 1);
  }
}
