#include #include #include #include #include #include class Solver { public: int n, m; int a[50000], b[50000]; bool solve() { for (int ni = 0; ni < n; ++ni) { edges[ni].clear(); has_visited[ni] = false; } for (int mi = 0; mi < m; ++mi) { edges[a[mi] - 1].push_back(b[mi] - 1); edges[b[mi] - 1].push_back(a[mi] - 1); } for (int ni = 0; ni < n; ++ni) { std::sort(edges[ni].begin(), edges[ni].end()); } has_visited[0] = true; return search(0, 4); } private: std::vector edges[50000]; bool has_visited[50000]; bool search(int cur, int r) { if (r == 0) { return edges[cur][0] == 0; } else { for (std::size_t i = 0; i < edges[cur].size(); ++i) { int nn = edges[cur][i]; if (not has_visited[nn]) { has_visited[nn] = true; if (search(nn, r - 1)) { return true; } has_visited[nn] = false; } } return false; } } }; int main() { Solver s; scanf("%d%d", &s.n, &s.m); for (int mi = 0; mi < s.m; ++mi) { scanf("%d%d", &s.a[mi], &s.b[mi]); } printf("%s\n", s.solve()? "YES": "NO"); return 0; }