import std.stdio; 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); 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; } alias S = Tuple!(int, "index", int, "depth", int, "prev"); bool[S] D; D[S(0, 0, -1)] = true; 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 >= 5) 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)); } } foreach (k, v; D) { if (k.index == 0 && k.depth == 5) { writeln("YES"); return; } } writeln("NO"); }