#include #define int long long //#define USE_FREOPEN //#define MUL_TEST #define FILENAME "circle" using namespace std; constexpr int N = 2e4 + 5; vector G[N],from[N]; void solve() { int n,m; cin >> n >> m; for (int i = 1; i <= m; i++) { int u,v; cin >> u >> v; G[u].push_back(v); G[v].push_back(u); } for (int v : G[1]) { for (int c : G[v]) { if (c != 1) { if (from[c].size() < 3) { from[c].push_back(v); } } } } for (int i = 2; i <= n; i++) { for (int c : G[i]) { for (int j : from[i]) { for (int k : from[c]) { if (j != c && j != k && k != i) { cout << "YES\n"; return; } } } } } cout << "NO\n"; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #ifdef USE_FREOPEN freopen(FILENAME ".in","r",stdin); freopen(FILENAME ".out","w",stdout); #endif int _ = 1; #ifdef MUL_TEST cin >> _; #endif while (_--) solve(); _^=_; return 0^_^0; }