#P11031. 『DABOI Round 1』Completely Unrelated

『DABOI Round 1』Completely Unrelated

Background

Problem Description

We know that in plane geometry, triangles are stable shapes.

Xiao L drew a graph on paper. He told you the number of points in the graph and which pairs of points are connected by edges. He wants to know whether this graph is stable.

We say a graph is stable if and only if: after choosing any one edge and fixing it so that it cannot move, then all the other edges and points cannot move either. Note that movement is only within the plane, i.e., reflections are not allowed. In particular, a single point is stable.

For example, a line segment or a triangle is stable, but a quadrilateral is not stable.

Note that you may assume stability has nothing to do with the lengths of edges. So as long as there exists a set of edge lengths that makes the graph stable, it is stable. If no such set of edge lengths can satisfy the condition, then it is unstable.

Input Format

The input consists of multiple lines.

The first line contains one positive integer TT, the number of test cases.

Then for each test case, the input contains m+1m + 1 lines:

  • Line 11 contains two integers, the number of vertices nn and the number of edges mm.
  • Lines 22 to m+1m + 1 each contain two integers, the indices of the two vertices connected by an edge.

Output Format

Output TT lines.

For each test case, output one line containing one string. Output Yes\tt Yes if the graph is stable, otherwise output No\tt No. In particular, if the given information cannot form a graph, output No\tt No.

2
3 3
1 2
2 3
1 3
3 2
1 2
2 3
Yes
No
1
4 5
1 2
2 3
3 4
4 1
1 3
Yes

Hint

Constraints

  • For 50%50\% of the testdata, n50n \le 50, m2×103m \le 2 \times 10^3.
  • For 100%100\% of the testdata, 1T101 \le T \le 10, 1n2×1021 \le n \le 2 \times 10^2, 0m2×1040 \le m \le 2 \times 10^4. Self-loops are guaranteed not to exist, but multiple edges may appear.

Translated by ChatGPT 5