#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; int main() { random_device rd; mt19937 mt(rd()); int N, M; cin >> N >> M; vector > G(N); while (M--) { int u, v; scanf("%d%d", &u, &v); u--; v--; G[u].push_back(v); G[v].push_back(u); } for (int t = 0; t < 10000; t++) { vector color(N); for (int u = 0; u < N; u++) color[u] = mt() % 4; vector a(N); a[0] = true; for (int c = 0; c < 4; c++) { vector _a(N); for (int u = 0; u < N; u++) if (a[u]) for (int v: G[u]) if (color[v] == c) _a[v] = true; a = _a; } for (int v: G[0]) if (a[v]) { cout << "YES" << endl; return 0; } } cout << "NO" << endl; }