import std.stdio; import std.algorithm; import std.typecons; import std.string; import std.array; import std.conv; import std.container; void main() { int N, M; readf("%d %d\n", &N, &M); alias E = Tuple!(int, int); bool[E] es; auto G = new int[][](N); foreach (i; 0 .. M) { int a, b; readf("%d %d\n", &a, &b); a--; b--; G[a] ~= b; G[b] ~= a; if (a > b) swap(a, b); es[E(a, b)] = true; } alias S = Tuple!(int, "index", int, "depth", int, "prev"); alias P = Tuple!(int, "v", int, "prev"); bool[S] D; D[S(0, 0, -1)] = true; P[] X; DList!S Q; Q.insert(S(0, 0, -1)); while (!Q.empty) { auto c = Q.front; Q.removeFront; int v = c[0]; int d = c[1]; int prev = c[2]; if (d == 2) { X ~= P(v, prev); continue; } foreach (nv; G[v]) { if (nv == prev) continue; int nd = d + 1; if (S(nv, nd, v) in D) continue; D[S(nv, nd, v)] = true; Q.insert(S(nv, nd, v)); } } for (auto i = 0; i < X.length; i++) { for (auto j = i + 1; j < X.length; j++) { int u = X[i].v; int v = X[j].v; if (u > v) swap(u, v); if (E(u, v) !in es) continue; auto vs = [u, v, X[i].prev, X[j].prev]; bool flag = true; foreach (a; 0 .. 4) { foreach (b; 0 .. 4) { if (a == b) continue; if (vs[a] == vs[b]) { flag = false; } } } if (flag) { writeln("YES"); return; } } } writeln("NO"); }