1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> #define Tp template<typename Ty> #define Ts template<typename Ty,typename... Ar> #define W while #define I inline #define RI register int #define LL long long #define Cn const #define CI Cn int& using namespace std; namespace Debug{ Tp I void _debug(Cn char* f,Ty t){cerr<<f<<'='<<t<<endl;} Ts I void _debug(Cn char* f,Ty x,Ar... y){W(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);} Tp ostream& operator<<(ostream& os,Cn vector<Ty>& V){os<<"[";for(Cn auto& vv:V) os<<vv<<",";os<<"]";return os;} #define gdb(...) _debug(#__VA_ARGS__,__VA_ARGS__) }using namespace Debug; namespace FastIO{ #define FS 100000 #define tc() (FA==FB&&(FB=(FA=FI)+fread(FI,1,FS,stdin),FA==FB)?EOF:*FA++) #define pc(c) (FC==FE&&(clear(),0),*FC++=c) int OT;char oc,FI[FS],FO[FS],OS[FS],*FA=FI,*FB=FI,*FC=FO,*FE=FO+FS; Tp I void read(Ty& x) {x=0;RI f=1;W(!isdigit(oc=tc())) f=oc^'-'?1:-1;W(x=(x<<3)+(x<<1)+(oc&15),isdigit(oc=tc()));x*=f;} Ts I void read(Ty& x,Ar&... y) {read(x),read(y...);} }using namespace FastIO; Cn int N=1e5+10,p=998244353; int n,k,g[N],C[(1<<11)+5]; vector<int> G[N],v; #define pb push_back I void DFS(CI x,CI fa){for(auto i:G[x]) i^fa&&(DFS(i,x),g[x]^=g[i]);x>1&&++C[g[x]];} struct LineBasic{ int d[13];I int Add(LL x){ RI i,flg=0;for(i=10;~i;i--) if(x>>i&1) if(d[i]) x^=d[i];else return d[i]=x; return 0; } }A[13]; I int dfs(CI x,CI nw){if(x>=v.size()) return 1;RI S=dfs(x+1,nw);if(A[nw+1]=A[nw],A[nw+1].Add(v[x])) S+=1LL*C[v[x]]*dfs(x+1,nw+1)%p,S%=p;return S;} int main(){ freopen("connected.in","r",stdin),freopen("connected.out","w",stdout); RI i,x,y;for(read(n,k),i=1;i<=n+k-1;i++) read(x,y),i<n?G[x].pb(y),G[y].pb(x),0:(++C[1<<i-n],g[x]^=(1<<i-n),g[y]^=(1<<i-n),0); for(DFS(1,0),i=1;i<(1<<k);i++) C[i]&&(v.pb(i),0);return printf("%d\n",dfs(0,0)),0; }
|