# Question :

Vlad found a flowerbed with graphs in his yard and decided to take one for himself. Later he found out that in addition to the usual graphs, $�$-flowers also grew on that flowerbed. A graph is called a $�$-flower if it consists of a simple cycle of length $�$, through each vertex of which passes its own simple cycle of length $�$ and these cycles do not intersect at the vertices. For example, $3$-flower looks like this:

Note that $1$-flower and $2$-flower do not exist, since at least $3$ vertices are needed to form a cycle.

Vlad really liked the structure of the $�$-flowers and now he wants to find out if he was lucky to take one of them from the flowerbed.

Input

The first line of input contains the single integer $�$ ($1\le �\le {10}^{4}$) — the number of test cases in the test.

The descriptions of the cases follow. An empty string is written before each case.

The first line of each case contains two integers $�$ and $�$ ($2\le �\le 2\cdot {10}^{5}$$1\le �\le min\left(2\cdot {10}^{5},\frac{�\cdot \left(�-1\right)}{2}\right)$) — the number of vertices and edges in the graph, respectively.

The next $�$ lines contain two integers each $�$ and $�$ ($1\le �,�\le �$$�\ne �$) — numbers of vertices connected by an edge. It is guaranteed that the graph does not contain multiple edges and self-loops.

It is guaranteed that the sum of $�$ over all test cases does not exceed $2\cdot {10}^{5}$. It is also guaranteed for the sum of $�$ over all test cases.

Output

Output $�$ lines, each of which is the answer to the corresponding test case. As an answer, output "YES" if Vlad's graph is a $�$-flower for some $�$, and "NO" otherwise.

You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

Examples

input
Copy
59 121 23 12 31 64 16 43 83 55 89 72 97 28 121 23 12 31 64 16 43 83 55 88 72 87 24 31 24 23 16 86 36 45 35 23 23 12 12 45 72 42 53 43 54 14 51 5
output
Copy
YES
NO
NO
NO
NO

input
Copy
42 11 28 91 28 48 26 46 54 73 23 72 59 122 92 86 96 86 56 19 89 39 18 38 75 73 31 21 32 3
output
Copy
NO
NO
NO
NO

# Explanation :

First from k-flower, number of nodes n=k*k and number of edges m=k*(k+1). Then there must be k nodes with degree 4, and other nodes with degree 2. If so, 4-nodes must form a cycle of size k (we can take all edges between 4-nodes and check if they're a cycle), and all other edges must form k cycles of size k, and each cycle contains one 4-node and k-1 2-nodes.

# Solution :

#include <bits/stdc++.h>
using namespace std;
#define ll long long int

vector<int> vis(200010);

int dfs(int root){
int ans = 1 - vis[root];
vis[root] = 1;
if(vis[c] == 0){
ans += dfs(c);
break;
}
}
return ans;
}

void solve(){
int n,m;
int a,b;

string s;
getline(cin, s);
getline(cin, s);
cin>>n>>m;
int sq1 = int(sqrt(n)),sq;

for(int i = sq1-2;i<sq1+3;i++){
if(i*i<=n){
sq = i;
}
}
vector<int> v(n,0);
for(int i = 0;i<m;i++){
cin>>a>>b;
a--;b--;
v[a]++;
v[b]++;

}

if(sq*sq != n || sq < 3){
cout<<"NO\n";
return;
}

int pp=0,np=0;

for(int i = 0;i<n;i++){
if(v[i] == 2){
np++;
}else if(v[i] == 4){
pp++;
vis[i] = 1;
}else{
cout<<"NO\n";
return;
}
}

for(int i = 0;i<n;i++){
if(v[i] == 4){
int dd = dfs(i);
if(dd != sq-1){
cout<<"NO\n";
return ;
}

}
}
int lst;
for(int i = 0;i<n;i++){
if(v[i] == 4){
vis[i] = 0;
lst = i;
}
}

if(dfs(lst) != sq){
cout<<"NO\n";
return;
}

if(pp == sq && np + pp == n ){
cout<<"YES\n";
}else{
cout<<"NO\n";
}

}

int main(){
ll t,n,x1,y1,x2,y2;
cin>>t;
while(t--){
solve();
}
return 0;

}

I Hope you liked it please tell me the suggestion in the comment below what shoud I change according to you.
And discuss the Approach in comment section if you want. share the solution with you frnds too.