#include #include #include #include #define repeat(i,n) for (int i = 0; (i) < (n); ++(i)) using namespace std; int main() { int n, m; cin >> n >> m; vector > g(n); repeat (i,m) { int a, b; cin >> a >> b; -- a; -- b; g[a].push_back(b); g[b].push_back(a); } const int root = 0; set d1; for (int i : g[root]) d1.insert(i); set d2; for (int i : g[root]) for (int j : g[i]) if (j != root) d2.insert(j); vector > g1(n); repeat (i,n) for (int j : g[i]) if (d1.count(j)) g1[i].push_back(j); bool ans = false; for (int i : d2) for (int j : d2) if (i < j) { assert (not g1[i].empty()); assert (not g1[j].empty()); if (g1[i].size() == 1 and g1[j].size() == 1 and g1[i][0] == g1[j][0]) continue; ans = true; goto done; } done: cout << (ans ? "YES" : "NO") << endl; return 0; }