#include #include #include #include using namespace std; int N, M; struct Node { int cnt=INT32_MAX; }; int main() { cin >> N >> M; vector > G(N+1); vector node(N + 1); node[1].cnt = 0; for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; G[a].push_back(b); G[b].push_back(a); } queue que; for (int i = 0; i < G[1].size(); i++) { que.push(G[1][i]); node[G[1][i]].cnt = node[1].cnt + 1; } bool flag = false; while (!que.empty()) { int p = que.front(); que.pop(); for (int i = 0; i < G[p].size(); i++) { if (node[G[p][i]].cnt == 2 && node[p].cnt == 2) flag = true; if (node[G[p][i]].cnt < node[p].cnt)continue; que.push(G[p][i]); node[G[p][i]].cnt = node[p].cnt + 1; } } if (flag)cout << "YES" << endl; else cout << "NO" << endl; return 0; }