#include #include #include #include using vertex = size_t; using vertex_set = size_t; using edge = std::pair; #include uint32_t naive(const size_t n, const size_t m, const std::vector &edges) { using edge_set = size_t; std::vector> cycles(n); for (edge_set s = 0; s < 1u << m; ++s) { atcoder::dsu uf(n); std::vector deg(n); for (size_t i = 0; i < m; ++i) if ((s >> i) & 1) { const auto &[u, v] = edges[i]; ++deg[u], ++deg[v]; uf.merge(u, v); } bool is_cycle = true; std::vector vs; for (vertex v = 0; v < n; ++v) { if (deg[v] == 2) vs.push_back(v); else is_cycle &= deg[v] == 0; } for (size_t i = 1; i < vs.size(); ++i) { is_cycle &= uf.same(vs[i - 1], vs[i]); } if (is_cycle) for (vertex v : vs) cycles[v].push_back(s); } uint32_t ans = 0; for (edge_set s = 0; s < 1u << m; ++s) { bool ok = true; for (vertex v = 0; v < n; ++v) { size_t cycle_count = 0; for (size_t c : cycles[v]) cycle_count += (c & s) == c; ok &= cycle_count <= 1; } ans += ok; } return ans; } int main() { size_t n, m; std::cin >> n >> m; std::vector edges(m); for (auto &[u, v] : edges) { std::cin >> u >> v; --u, --v; } std::cout << naive(n, m, edges) << '\n'; }