#include #define show(x) cerr << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair; using vi = vector; template ostream& operator<<(ostream& os, const vector& v) { os << "sz:" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = 1e9 + 7; template constexpr T INF = numeric_limits::max() / 100; struct Graph { Graph(const int n) { edge.resize(n); } void addEdge(const int from, const int to) { edge[from].push_back(to); edge[to].push_back(from); } vector> edge; }; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; Graph g(N); using P = pair; vector

edge(M); for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--, b--; g.addEdge(a, b); edge[i] = make_pair(a, b); } vector dist1; vector isdist1(N, false); for (const int neighbor : g.edge[0]) { dist1.push_back(neighbor); isdist1[neighbor] = true; } vector passnum(N, 0); vector prev(N); for (const int from : dist1) { for (const int to : g.edge[from]) { if (to == 0) { continue; } passnum[to]++; prev[to] = from; } } for (const auto& e : edge) { const int u = e.first; const int v = e.second; if (passnum[u] == 0 or passnum[v] == 0) { continue; } if (passnum[u] > 1 and passnum[v] > 1) { cout << "YES" << endl; return 0; } else if (passnum[u] > 1) { if (prev[v] == u) { continue; } else { cout << "YES" << endl; return 0; } } else if (passnum[v] > 1) { if (prev[u] == v) { continue; } else { cout << "YES" << endl; return 0; } } if (isdist1[u] or isdist1[v]) { continue; } if (prev[u] == prev[v]) { continue; } cout << "YES" << endl; return 0; } cout << "NO" << endl; return 0; }