#include using namespace std; #define modulo 1000000007 #define mod(mod_x) ((((long long)mod_x+modulo))%modulo) #define Inf 10000000000000000 struct unionfind{ vector data; vector size; unionfind(int n){ for(int i=0;isize[y])swap(x,y); data[x]=y; size[y]+=size[x]; return true; } bool check(int x,int y){ return (find(x)==find(y)); } int get_size(int x){ int X = find(x); return size[X]; } }; int main(){ int N,Md,Mw; cin>>N>>Md>>Mw; unionfind uf1(N),uf2(N); for(int i=0;i> S(N); for(int i=0;i cnt(N,0); for(int i=0;i