#include #include #include #include using namespace std; struct state { int node, prev, prevprev, 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, -1, 0 }); used[0][0] = true; while (!q.empty()) { state p = q.front(); q.pop(); int u = p.node, s = p.step, prev = p.prev, prevprev = p.prevprev; if (s == 5) continue; for (auto v : g[u]) if (!used[v][s + 1]) { if ((s + 1 != 5 && v == 0) || v == prevprev) continue; used[v][s + 1] = true; q.push({v, u, prev, s + 1}); } } puts(used[0][5] ? "YES" : "NO"); return 0; }