#include "bits/stdc++.h" using namespace std; #define int long long #define FOR(i, a, b) for(int i=(a);i<(b);i++) #define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--) #define REP(i, n) for(int i=0; i<(n); i++) #define RREP(i, n) for(int i=(n-1); i>=0; i--) #define REP1(i, n) for(int i=1; i<=(n); i++) #define RREP1(i, n) for(int i=(n); i>=1; i--) #define ALL(a) (a).begin(),(a).end() #define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end()); #define CONTAIN(a, b) find(ALL(a), (b)) != (a).end() #define out(...) printf(__VA_ARGS__) #if DEBUG #define debug(...) printf(__VA_ARGS__) #else #define debug(...) /* ... */ #endif templatebool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b P[SIZE]; const int MAX = 5e5; const int MOD = 998244353; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } long long COM(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; if (!fac[n]) COMinit(); return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } //int P(int n, int k) { // if (n < k) return 0; // if (n < 0 || k < 0) return 0; // if (!fac[n]) COMinit(); // return (fac[n] * finv[n-k]) % MOD; //} template struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) { } ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt &operator/=(ModInt that) { return *this *= that.inverse(); } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } ModInt operator/(ModInt that) const { return ModInt(*this) /= that; } ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } return ModInt(u); } bool operator==(ModInt that) const { return x == that.x; } bool operator!=(ModInt that) const { return x != that.x; } ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; } }; template ostream& operator<<(ostream& st, const ModInt a) { st << a.get(); return st; }; template ModInt operator^(ModInt a, unsigned long long k) { ModInt r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; } typedef ModInt<998244353> mint; /* 完全グラフのサイクル数-1つ抜いたサイクル数+... (包除原理) 選ぶ辺が1つの場合、それ以外を一つも選ばないパターンを除く必要あり 同じ頂点が3回出てきたらx すべての頂点が複数回なら→1通り 結合後の辺の数...k通り 辺に含まれる頂点数...g個 辺に含まれない頂点をl個選ぶ場合...COM(N-g,l) * (k+l-1)! * 2^(k-1) */ void solve() { cin>>N>>M; REP(i,M) { cin>>P[i].first>>P[i].second; P[i].first--; P[i].second--; } COMinit(); mint ans = 0; REP(i,1LL< C; REP(j,M) if (i & 1LL<= 3) ok = false; if (p.second%2) all_even = false; } if (!ok) continue; if (C.size() && all_even) { ans += 1; continue; } bitset<20> bs(i); int k = bs.count(); // 辺の数 int g = C.size(); // 頂点数 int start = 0; if (g==0) start = 3; if (g==2) start = 1; FOR(l,start,N-g+1) { mint add = 1; add *= COM(N-g,l); if (k+l>2) add *= fac[k+l-1] * inv[2]; if (k) add *= mint(2)^(k-1); if (k%2==0) { ans += add; } else { ans -= add; } } } cout << ans << endl; }