#include #include #include #include using namespace std; struct state { int node, prev, step; }; int main() { int n, m; scanf("%d%d", &n, &m); vector> g(n); for (int i = 0; i < m; i ++) { int a, b; scanf("%d%d", &a, &b); a --, b --; g[a].push_back(b); g[b].push_back(a); } vector> used(n, vector (6)); queue q; q.push({ 0, -1, 0 }); used[0][0] = true; while (!q.empty()) { state p = q.front(); q.pop(); int u = p.node; int s = p.step; int prev = p.prev; if (s == 5) continue; for (auto v : g[u]) if (!used[v][s + 1]) { if (v == prev) continue; if (s + 1 != 5 && v == 0) continue; used[v][s + 1] = true; q.push({v, u, s + 1}); } } puts(used[0][5] ? "YES" : "NO"); return 0; }