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++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}


int n,m;

class dinic {
  typedef long long ll;
  vector<int> level;
  vector<int> iter;

  void bfs(int s) {
    fill(level.begin(), level.end(), -1);
    queue<int> q;
    level[s] = 0;
    q.push(s);
    while (!q.empty()) {
      int v = q.front();q.pop();
      for (int i = 0; i < (int)g[v].size(); i++) {
        edge &e = g[v][i];
        if (e.cap > 0 && level[e.to] < 0) {
          level[e.to] = level[v] + 1;
          q.push(e.to);
        }
      }
    }
  }

  ll dfs(int v, int t, ll f) {
    if (v == t) return f;
    for (int &i = iter[v]; i < (int)g[v].size(); i++) {
      edge &e = g[v][i];
      if (e.cap > 0 && level[v] < level[e.to]) {
        ll d = dfs(e.to, t, min(f,e.cap));
        if (d > 0) {
          e.cap -= d;
          g[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

public:
  struct edge { int to; ll cap; int rev; };
  vector<vector<edge>> g;
  const ll INF = 0x3f3f3f3f3f3f3f3f;

  dinic(int n) {
    g.resize(n); level.resize(n); iter.resize(n);
  }

  void add_edge(int u, int v, int cap) {
    g[u].push_back((edge){v,cap,(int)g[v].size()});
    g[v].push_back((edge){u,0,(int)g[u].size()-1});
  }

  ll max_flow(int s, int t) {
    ll flow = 0;
    while (true) {
      bfs(s);
      if (level[t] < 0) return flow;
      fill(iter.begin(), iter.end(), 0);
      ll f;
      while ((f = dfs(s,t,INF)) > 0) flow += f;
    }
  }
};


int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> m;
  int a,b;
  dinic d(n);
  forn(i,m) {
    cin >> a >> b;
    a--,b--;
    d.add_edge(a, b, 1);
    d.add_edge(b, a, 1);
  }

  bool even = all_of(d.g.begin(),d.g.end(),[](vector<dinic::edge> v) { return v.size() % 4 == 0; });

  vi four;
  int six = 0;
  forn(i,n) {
    if (d.g[i].size() == 8) four.push_back(i);
    if (d.g[i].size() >= 12) six++;
  }

  bool ok;
  if (even && (four.size() >= 3 || six > 0)) ok = true;
  else if (!even || four.size() <= 1) ok = false;
  else {
    ll f = d.max_flow(four[0], four[1]);
    ok = f < 4;
  }

  if (ok)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}