#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].insert(j); bool ans = false; for (int i : d2) for (int j : d2) if (i < j) { bool g1_i_count_j = g1[i].count(j); g1[i].erase(j); bool g1_j_count_i = g1[j].count(i); g1[j].erase(i); if (not g1[i].empty() and not g1[j].empty()) { if (not (g1[i].size() == 1 and g1[j].size() == 1 and g1[i] == g1[j])) { ans = true; } } if (g1_i_count_j) g1[i].insert(j); if (g1_j_count_i) g1[j].insert(i); if (ans) goto done; } done: cout << (ans ? "YES" : "NO") << endl; return 0; }