#include #include // #include // https://github.com/amiast/cpp-utility #ifndef KOTONE_RANDOM_HPP #define KOTONE_RANDOM_HPP 1 #include namespace kotone { // Returns a random unsigned 64-bit integer. uint64_t randint() { static std::random_device rd; static std::mt19937_64 gen(rd()); return gen(); } // Reference: https://codeforces.com/blog/entry/62393 uint64_t splitmix64(uint64_t x) noexcept { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } // A randomized hash for integers. struct randomized_hash { std::size_t operator()(uint64_t x) const { static const uint64_t SEED = randint(); return splitmix64(x ^ SEED); } }; } // namespace kotone #endif // KOTONE_RANDOM_HPP int main() { int N, M; std::cin >> N >> M; std::vector> graph(N); while (M--) { int u, v; std::cin >> u >> v; u--, v--; graph[u].push_back(v); graph[v].push_back(u); } for (int t = 0; t < 100; t++) { std::vector color(N); for (int i = 1; i < N; i++) color[i] = kotone::randint() % 4; std::vector> dp(16, std::vector(N)); for (int j : graph[0]) dp[1 << color[j]][j] = true; for (int k = 0; k < 16; k++) { for (int i = 1; i < N; i++) { if (!dp[k][i]) continue; for (int j : graph[i]) { if (j == 0 || k >> color[j] & 1) continue; dp[k | 1 << color[j]][j] = true; } } } for (int j : graph[0]) { if (!dp[15][j]) continue; std::cout << "YES" << std::endl; return 0; } } std::cout << "NO" << std::endl; }