P27122 [AtCoder] Broken Christmas Tree
普及+
题目描述

Problem Description

It's the Christmas season. The rabbit is making a Christmas tree for a Christmas party. However, the rabbit is clumsy and hasn't been able to make the tree at all. To make matters worse, the rabbit has broken several branches that were meant to be parts of the tree. The party is about to start, so the rabbit needs to hurry and make the Christmas tree.

The Christmas tree the rabbit is trying to make is an undirected connected graph consisting of $ N $ vertices and $ N-1 $ edges. Each vertex is numbered from $ 1 $ to $ N $. Basically, any edge formed by any pair of vertices $ (u, v) $ can be used for the Christmas tree. However, the rabbit has broken $ M $ edges, so these broken $ M $ edges cannot be used for the Christmas tree.

We would like you to make the Christmas tree for the rabbit.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ p_1 $ $ q_1 $ $ p_2 $ $ q_2 $ : $ p_M $ $ q_M $

  • The first line contains two integers $N, M\ (1 \leq N \leq 2 \times 10^5, 0 \leq M \leq 2 \times 10^5)$ separated by spaces.
  • The following $ M $ lines contain two integers $p_i, q_i\ (1 \leq p_i, q_i \leq N, p_i \neq q_i)$. This indicates that the edge $ (p_i, q_i) $ is a broken edge. It is guaranteed that the $ M $ broken edges are distinct.

Output Format

If it is not possible to make the Christmas tree under the given conditions, output No.

Otherwise, first output Yes, and then output $ N-1 $ lines with two integers each separated by spaces. Let the two integers on the $i+1\ (1 \leq i \leq N-1)$ line be $ u_i, v_i $, which indicates that the edge $ (u_i, v_i) $ is used in the Christmas tree.

If there are multiple valid solutions, any one of them will be considered correct.

Sample Input and Output

Sample Input #1

5 1
1 5

Sample Output #1

Yes
1 2
1 3
1 4
2 5

Sample Input #2

4 3
1 2
1 3
2 3

Sample Output #2

Yes
1 4
2 4
3 4

Sample Input #3

5 8
3 5
3 4
2 4
5 1
2 3
5 4
4 1
1 3

Sample Output #3

No

Notes/Hints

Input/Output Examples

Your output should strictly follow the following format:

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 1 1 5
样例输出
Yes 1 2 1 3 1 4 2 5