#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using Int = long long; template ostream &operator<<(ostream &os, const pair &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template ostream &operator<<(ostream &os, const vector &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; } template void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; } template bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; } #define COLOR(s) ("\x1b[" s "m") // as * bs // ZT: T[2^n][n+1] template vector setMul(int n, const vector &as, const vector &bs, ZT zas, ZT zbs) { assert(static_cast(as.size()) == 1 << n); assert(static_cast(bs.size()) == 1 << n); // ranked for (int h = 0; h < 1 << n; ++h) { memset(zas[h], 0, (n + 1) * sizeof(T)); zas[h][__builtin_popcount(h)] = as[h]; } for (int h = 0; h < 1 << n; ++h) { memset(zbs[h], 0, (n + 1) * sizeof(T)); zbs[h][__builtin_popcount(h)] = bs[h]; } // zeta for (int w = 1; w < 1 << n; w <<= 1) { for (int h0 = 0; h0 < 1 << n; h0 += w << 1) for (int h = h0; h < h0 + w; ++h) { for (int k = 0; k <= n; ++k) zas[h + w][k] += zas[h][k]; } } for (int w = 1; w < 1 << n; w <<= 1) { for (int h0 = 0; h0 < 1 << n; h0 += w << 1) for (int h = h0; h < h0 + w; ++h) { for (int k = 0; k <= n; ++k) zbs[h + w][k] += zbs[h][k]; } } // product for (int h = 0; h < 1 << n; ++h) { for (int k = n; k >= 0; --k) { T t = 0; for (int l = 0; l <= k; ++l) t += zas[h][l] * zbs[h][k - l]; zas[h][k] = t; } } // moebius for (int w = 1; w < 1 << n; w <<= 1) { for (int h0 = 0; h0 < 1 << n; h0 += w << 1) for (int h = h0; h < h0 + w; ++h) { for (int k = 0; k <= n; ++k) zas[h + w][k] -= zas[h][k]; } } // unrank vector cs(1 << n); for (int h = 0; h < 1 << n; ++h) cs[h] = zas[h][__builtin_popcount(h)]; return cs; } // exp(as) // assume as[0] == 0 // exp(a0 + a1 X) = exp(a0) + exp(a0) a1 X // ZT1: T[2^(n-1)][n] // ZT: T[2^n][n+1] template vector setExp(int n, const vector &as, ZT1 zas, ZT zbs) { assert(static_cast(as.size()) == 1 << n); assert(as[0] == 0); zbs[0][0] = 1; for (int m = 0; m < n; ++m) { // ranked a[2^m, 2^(m+1)) for (int h = 0; h < 1 << m; ++h) { memset(zas[h], 0, (m + 1) * sizeof(T)); zas[h][__builtin_popcount(h)] = as[(1 << m) + h]; } // zeta for (int w = 1; w < 1 << m; w <<= 1) { for (int h0 = 0; h0 < 1 << m; h0 += w << 1) for (int h = h0; h < h0 + w; ++h) { for (int k = 0; k <= m; ++k) zas[h + w][k] += zas[h][k]; } } for (int h = 0; h < 1 << m; ++h) { // zeta zbs[h][m + 1] = 0; memcpy(zbs[(1 << m) + h], zbs[h], ((m + 1) + 1) * sizeof(T)); // product for (int k = 0; k <= m; ++k) for (int l = 0; l <= m - k; ++l) { zbs[(1 << m) + h][k + l + 1] += zbs[h][k] * zas[h][l]; } } } // moebius for (int w = 1; w < 1 << n; w <<= 1) { for (int h0 = 0; h0 < 1 << n; h0 += w << 1) for (int h = h0; h < h0 + w; ++h) { for (int k = 0; k <= n; ++k) zbs[h + w][k] -= zbs[h][k]; } } // unrank vector bs(1 << n); for (int h = 0; h < 1 << n; ++h) bs[h] = zbs[h][__builtin_popcount(h)]; return bs; } // \sum[0<=i<=n] fs[i] as^i/i! // assume as[0] == 0 // f(a0 + a1 X) + f(a0) + f'(a0) a1 X // ZT1: T[2^(n-1)][n] // ZT: T[2^(n+1)][n+1] template vector setCom(int n, const vector &fs, const vector &as, ZT1 zas, ZT zbs) { assert(static_cast(fs.size()) == n + 1); assert(static_cast(as.size()) == 1 << n); assert(as[0] == 0); // zbs[2^(n-i), 2^(n-i+1)): composite f^(i) for (int i = 0; i <= n; ++i) zbs[1<<(n-i)][0] = fs[i]; for (int m = 0; m < n; ++m) { // ranked a[2^m, 2^(m+1)) for (int h = 0; h < 1 << m; ++h) { memset(zas[h], 0, (m + 1) * sizeof(T)); zas[h][__builtin_popcount(h)] = as[(1 << m) + h]; } // zeta for (int w = 1; w < 1 << m; w <<= 1) { for (int h0 = 0; h0 < 1 << m; h0 += w << 1) for (int h = h0; h < h0 + w; ++h) { for (int k = 0; k <= m; ++k) zas[h + w][k] += zas[h][k]; } } for (int i = 0; i < n - m; ++i) { for (int h = 0; h < 1 << m; ++h) { // zeta zbs[(1<<(n-i)) + h][m + 1] = 0; memcpy(zbs[(1<<(n-i)) + (1 << m) + h], zbs[(1<<(n-i)) + h], ((m + 1) + 1) * sizeof(T)); // product for (int k = 0; k <= m; ++k) for (int l = 0; l <= m - k; ++l) { zbs[(1<<(n-i)) + (1 << m) + h][k + l + 1] += zbs[(1<<(n-(i+1))) + h][k] * zas[h][l]; } } } } // moebius for (int w = 1; w < 1 << n; w <<= 1) { for (int h0 = 0; h0 < 1 << n; h0 += w << 1) for (int h = h0; h < h0 + w; ++h) { for (int k = 0; k <= n; ++k) zbs[(1< bs(1 << n); for (int h = 0; h < 1 << n; ++h) bs[h] = zbs[(1< vector setComPoly(int n, vector fs, vector as, ZT1 zas, ZT zbs) { assert(static_cast(as.size()) == 1 << n); const int fsLen = fs.size(); if (fsLen == 0) return vector(1 << n, 0); vector gs(n + 1); for (int i = 0; i <= n; ++i) { T t = 0; for (int j = fsLen; --j >= 0; ) (t *= as[0]) += fs[j]; gs[i] = t; for (int j = 1; j < fsLen; ++j) fs[j - 1] = j * fs[j]; fs[fsLen - 1] = 0; } as[0] = 0; return setCom(n, gs, as, zas, zbs); } //////////////////////////////////////////////////////////////////////////////// using U = unsigned long long; constexpr int MAX_N = 13; U zas[1 << (MAX_N + 1)][MAX_N + 1]; U zbs[1 << (MAX_N + 1)][MAX_N + 1]; int N, M; vector A, B; U dp[1 << MAX_N][MAX_N]; int main() { for (; ~scanf("%d%d", &N, &M); ) { A.resize(M); B.resize(M); for (int i = 0; i < M; ++i) { scanf("%d%d", &A[i], &B[i]); --A[i]; --B[i]; if (A[i] > B[i]) { swap(A[i], B[i]); } } vector adj(N, 0); for (int i = 0; i < M; ++i) { adj[A[i]] |= 1 << B[i]; adj[B[i]] |= 1 << A[i]; } // cycle vector cs(1 << N, 0); memset(dp, 0, sizeof(dp)); for (int r = 0; r < N; ++r) { dp[1 << r][r] = 1; for (int p = 1 << r; p < 1 << (r + 1); ++p) { for (int u = 0; u <= r; ++u) if (p & 1 << u) { for (int v = 0; v < r; ++v) if (!(p & 1 << v)) { if (adj[u] >> v & 1) { dp[p | 1 << v][v] += dp[p][u]; } } if (adj[u] >> r & 1) { cs[p] += dp[p][u]; } } } } for (int i = 0; i < M; ++i) cs[1 << A[i] | 1 << B[i]] -= 1; for (int p = 0; p < 1 << N; ++p) cs[p] /= 2; // cerr<<"cs = "< ds(1 << (N - 1)), es(1 << (N - 1)); for (int p = 0; p < 1 << r; ++p) for (int q = 0; q < 1 << (N-1-r); ++q) { ds[p | q << r] = cs[p | 1 << r | q << (r + 1)]; es[p | q << r] = __builtin_popcount(p & adj[r]) * cs[p | q << (r + 1)]; } es = setExp(N - 1, es, zas, zbs); ds = setMul(N - 1, ds, es, zas, zbs); for (int p = 0; p < 1 << r; ++p) for (int q = 0; q < 1 << (N-1-r); ++q) { cs[p | 1 << r | q << (r + 1)] = ds[p | q << r]; } // cerr<<"cs = "<