#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template vector> vec2d(int n, int m, T v){ return vector>(n, vector(m, v)); } template vector>> vec3d(int n, int m, int k, T v){ return vector>>(n, vector>(m, vector(k, v))); } template void print_vector(vector v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } using mint = atcoder::modint998244353; ostream& operator<<(ostream& os, const mint& m){ os << m.val(); return os; } template class Compress{ public: vector data; int offset; Compress(vector data_, int offset=0): offset(offset){ data = data_; sort(begin(data), end(data)); data.erase(unique(begin(data), end(data)), end(data)); }; int operator[](T x) { auto p = lower_bound(data.begin(), data.end(), x); assert(x == *p); return offset+(p-data.begin()); } T inv(int x){ return data[x-offset]; } int size(){ return data.size(); } }; #define N_MAX 2000002 mint inv[N_MAX],fac[N_MAX],finv[N_MAX]; void init(){ const ll MOD = mint::mod(); fac[0]=1;fac[1]=1; finv[0]=1;finv[1]=1; inv[1]=1; for(int i=2;i> n >> m >> k; vector x(k), y(k); vector v; for(int i = 0; i < k; i++){ cin >> x[i] >> y[i]; x[i]--; y[i]--; v.push_back(x[i]); v.push_back(y[i]); } auto cp = Compress(v); vector prev_mask(cp.size()); for(int i = 0; i < k; i++){ int u = cp[x[i]]; int v = cp[y[i]]; prev_mask[v] |= 1< 0){ ans += cnt_main*comb(n-1, s)*dp[all_bits][k]*fac[cnt_main+cnt_sub-1]; } if(k == 1 && s > 0){ ans += comb(n-1, s-1)*dp[all_bits][k]*fac[cnt_main+cnt_sub]; } } cout << ans << endl; }