#P7083. Pty loves graph

    ID: 5940 远端评测题 10000ms 512MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>2021“MINIEYE杯”中国大学生算法设计超级联赛(10)

Pty loves graph

Problem Description

Given a undirected graph and a Hamiltonian cycle of it, output whether it is a planar graph.

For convenience, the indices of vertex are advancely relabeled so that the given Hamiltonian cycle is 1--2--3--4--...--(n-1)--n--1. The edges on this cycle are not given in the input.

Notice that there might be self loops and multiedges in the graph.

There are T test cases in total.

Input

The first line contains one integer T – the number of test cases.

For each test case:

The first line, two positive integer N,M - the number of vertices and edge besides the Hamiltonian cycle. Following m lines, two positive integer x,y, representing an edge (x,y)

1 ≤ T ≤ 26
1 ≤ N,M ≤ 5×$10^5$ , $\sum N$,$ \sum M ≤ 3 \times 10^6$.
1 ≤ x,y ≤ N

Output

For each test case, output ”Yes” or ”No” in one line.

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