#include using namespace std; struct UnionFind{ vector parent; vector numberOfElements;//根ノードのみ有効 UnionFind(int n){ parent.resize(n); numberOfElements.resize(n); for(int i=0;i path(0); int pointer=a; while(parent[pointer]!=-1){ path.push_back(pointer); pointer=parent[pointer]; } for(int i:path){ parent[i]=pointer; } return pointer; } void unite(int a,int b){ int p=find(a); int q=find(b); if(p==q){ return; } if(numberOfElements[p]>N; int edges[N-1][3]; long long cur=1,ans=0; for(int i=0;i>edges[i][j]; edges[i][j]-=(j<2); } } for(int i=0;i<32;++i){ long long temp=0; UnionFind U(N); for(int j=0;j>=1; } ans=(ans+temp*cur)%mod; cur=(cur*2)%mod; } cout<