#include #include using namespace std; int main() { int N, M; cin >> N >> M; vector graph[20010]; for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; graph[a].push_back(b); graph[b].push_back(a); } vector > p; for (int i = 0; i < graph[1].size(); i++) { int a = graph[1][i]; for (int j = 0; j < graph[a].size(); j++) { int b = graph[a][j]; if (b == 1) continue; p.push_back(make_pair(a, b)); } } for (int i = 0; i+1 < p.size(); i++) { int a1 = p[i].first, b1 = p[i].second, a2 = p[i + 1].first, b2 = p[i + 1].second; if ( b1 == b2) { cout << "YES" << endl; return 0; } } cout << "NO" << endl; return 0; }