#include #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]; set par[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); } set two; for(int c : G[1]) { for(int cc : G[c]) { if(cc == 1) continue; par[cc].insert(c); two.insert(cc); } } for(int cc : two) { for(int ccc : G[cc]) { for(int p : par[cc]) { if(p == ccc) continue; if(two.find(ccc) == two.end()) continue; int rem = par[ccc].size(); if(par[ccc].find(p) != par[ccc].end()) rem--; if(par[ccc].find(cc) != par[ccc].end()) rem--; if(rem > 0) { cout << "YES" << endl; return 0; } } } } cout << "NO" << endl; }