#include #include #include #include #include #include #include using namespace std; template void setmin(T& a, T& b) { a = min(a, b); } template void setmax(T& a, T& b) { a = max(a, b); } typedef pair P; int N, M; vector G[20001]; int group[20001]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M; for(int i = 0; i < M; i++) { int a, b; cin >> a >> b; G[a].push_back(b); G[b].push_back(a); } group[1] = 0; int g = 1; vector

one; for(int c : G[1]) { one.push_back(P(c, g)); group[c] = g; g++; } vector

two; for(P p : one) { for(int c : G[p.first]) { if(c == 1 || group[c] != 0) continue; group[c] = p.second; two.push_back(P(c, p.second)); } } for(P p : two) { for(int c : G[p.first]) { if(group[c] != 0 && group[c] != p.second) { cout << "YES" << endl; return 0; } } } cout << "NO" << endl; }