#include using namespace std; #define _p(...) (void)printf(__VA_ARGS__) #define forr(x,arr) for(auto&& x:arr) #define _overload3(_1,_2,_3,name,...) name #define _rep2(i,n) _rep3(i,0,n) #define _rep3(i,a,b) for(int i=int(a);i=int(a);i--) #define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__) #define ALL(x) (x).begin(), (x).end() #define BIT(n) (1LL<<(n)) #define SZ(x) ((int)(x).size()) #define fst first #define snd second typedef vector vi;typedef vector vvi;typedef pair pii;typedef vector vpii; typedef long long ll; void Main() { int N, M; scanf("%d%d", &N, &M); vvi E(N); vpii es(M); vector d1(N); vector d2(N); rep(i, M) { int u, v; scanf("%d%d", &u, &v); u--; v--; E[u].push_back(v); E[v].push_back(u); if (u > v) swap(u, v); es[i] = {u, v}; if (u == 0) d1[v] = 1; } rep(i, M) { if (d1[es[i].fst] == 1) { d2[es[i].snd] = 1; } if (d1[es[i].snd] == 1) { d2[es[i].fst] = 1; } } //cout << "d1:"; rep(ii,SZ(d1)) cout << ' ' << d1[ii]; cout << endl; //cout << "d2:"; rep(ii,SZ(d2)) cout << ' ' << d2[ii]; cout << endl; rep(i, M) { int u = es[i].fst; int v = es[i].snd; if (d2[u] && d2[v]) { set c; forr(nc, E[u]) if (d1[nc]) { c.insert(nc); } forr(nc, E[v]) if (d1[nc]) { c.insert(nc); } if (SZ(c) >= 2) { puts("YES"); return; } } } puts("NO"); } int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }