Problem:
Score : 800 points

Problem Statement

You are given a simple connected undirected graph consisting of N vertices and M edges.
The vertices are numbered 1 to N, and the edges are numbered 1 to M.

Edge i connects Vertex a_i and b_i bidirectionally.

Determine if three circuits (see Notes) can be formed using each of the edges exactly once.

Notes

A circuit is a cycle allowing repetitions of vertices but not edges.

Constraints

All values in input are integers.

1 \leq N,M \leq 10^{5}

1 \leq a_i, b_i \leq N

The given graph is simple and connected.

Input

Input is given from Standard Input in the following format:

N M
a_1 b_1
:
a_M b_M

Output

If three circuits can be formed using each of the edges exactly once, print Yes; if they cannot, print No.

Sample Input 1

7 9
1 2
1 3
2 3
1 4
1 5
4 5
1 6
1 7
6 7

Sample Output 1

Yes

Three circuits can be formed using each of the edges exactly once, as follows:

Sample Input 2

3 3
1 2
2 3
3 1

Sample Output 2

No

Three circuits are needed.

Sample Input 3

18 27
17 7
12 15
18 17
13 18
13 6
5 7
7 1
14 5
15 11
7 6
1 9
5 4
18 16
4 6
7 2
7 11
6 3
12 14
5 2
10 5
7 8
10 15
3 15
9 8
7 15
5 16
18 15

Sample Output 3

Yes

Solution in C++ (GCC 9.2.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
const int MAXN = 200005;
vector<int> E[MAXN];
vector<int> findCycle(int n) {
	vector<int> vis(n + 1), par(n + 1), cycle;
	function<bool(int)> dfs = [&](int x) {
		vis[x] = 1;
		for (int y : E[x]) {
			if (!vis[y]) {
				par[y] = x;
				if (dfs(y)) return true;
			} else if (vis[y] == 1) {
				// Back-edge.
				for (;;) {
					cycle.push_back(x);
					if (x == y) break;
					x = par[x];
				}
				reverse(cycle.begin(), cycle.end());
				return true;
			}
		}
		vis[x] = 2;
		return false;
	};
	for (int i = 1; i <= n; ++i)
		if (!vis[i] && dfs(i)) break;
	return cycle;
}
set<pair<int, int>> badEdges;
bool used[MAXN];
int cnt;
void dfs(int x) {
	used[x] = true;
	++cnt;
	for (int y : E[x]) {
		if (badEdges.count({x, y})) continue;
		if (used[y]) continue;
		dfs(y);
	}
}
void no() {
	printf("No\n");
	exit(0);
}
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	vector<int> deg(n + 1);
	for (int i = 0; i < m; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
		++deg[a];
		++deg[b];
	}
	bool all2 = true;
	for (int i = 1; i <= n; ++i) {
		if (deg[i] & 1) no();
		else if (deg[i] != 2) all2 = false;
	}
	if (all2) no();
	auto cycle = findCycle(n);
	assert(!cycle.empty());
	int x = cycle[0];
	cycle.push_back(x);
	for (int i = 0; i + 1 < cycle.size(); ++i) {
		badEdges.insert({cycle[i], cycle[i + 1]});
		badEdges.insert({cycle[i + 1], cycle[i]});
		--deg[cycle[i]];
		--deg[cycle[i + 1]];
	}
	all2 = true;
	for (int i = 1; i <= n; ++i) {
		if (deg[i] > 0 && deg[i] != 2) all2 = false;
	}
	int comps = 0;
	for (int i = 1; i <= n; ++i) {
		if (used[i]) continue;
		cnt = 0;
		dfs(i);
		if (cnt > 1) ++comps;
	}
	assert(comps > 0);
	if (all2 && comps == 1) no();
	else printf("Yes\n");
}