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; } auto D = new bool[][](N, 6); foreach (i; 0 .. N) D[i][] = false; D[0][0] = true; alias S = Tuple!(int, int); DList!S Q; Q.insert(S(0, 0)); while (!Q.empty) { auto c = Q.front; Q.removeFront; int v = c[0]; int d = c[1]; D[v][d] = true; if (d >= 5) continue; foreach (nv; G[v]) { int nd = d + 1; if (D[nv][nd]) continue; D[nv][nd] = true; Q.insert(S(nv, nd)); } } writeln(D[0][5] ? "YES" : "NO"); }