#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; #define rep(cur,k) for (int cur = 0; cur < (int)(k); cur++) #define all(cnt) begin(cnt), end(cnt) const int INF = 1e9; int n, m; vector> g; vector dist; vector> s; int main() { srand(time(0)); while (cin >> n >> m) { g.assign(n, {}); for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; --a; --b; g[a].emplace_back(b); g[b].emplace_back(a); } queue q; q.push(0); dist.assign(n, INF); dist[0] = 0; while (q.size()) { int cur = q.front(); q.pop(); for (auto &dst : g[cur]) { if (dist[dst] == INF) { q.push(dst); dist[dst] = dist[cur] + 1; } } } s.assign(n, {}); for (int i = 0; i < n; i++) { vector &v = s[i]; for (auto j : g[i]) { if (dist[j] == 1) { v.push_back(j); } } random_shuffle(v.begin(), v.end()); v.resize(min(v.size(), 50)); } bool ok = false; for (int i = 0; i < n; i++) { for (auto &j : g[i]) { auto &S = s[i]; auto &T = s[j]; for (auto &u : S) for (auto &v : T) { if (u == j) continue; if (v == i) continue; if (u != v) ok = true; } } } cout << (ok ? "YES" : "NO") << endl; } }