/* -*- coding: utf-8 -*- * * 408.cc: No.408 五輪ピック - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 20000; const int L = 5; /* typedef */ typedef vector vi; /* global variables */ vi nbrs[MAX_N]; bool used[MAX_N]; /* subroutines */ bool rec(int u, int ul, int st) { vi &nbru = nbrs[u]; int vl = ul + 1; for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) { int &v = *vit; if (v == st) { if (vl == L) return true; } else if (! used[v] && vl < L) { used[v] = true; if (rec(v, vl, st)) return true; used[v] = false; } } return false; } /* main */ int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int ai, bi; cin >> ai >> bi; ai--, bi--; nbrs[ai].push_back(bi); nbrs[bi].push_back(ai); } used[0] = true; bool ok = rec(0, 0, 0); cout << (ok ? "YES" : "NO") << endl; return 0; }