#include #include #include using namespace std; class union_find{ int *parent,*s,n; public: int root(int a){return parent[a]==a?a:(parent[a]=root(parent[a]));} union_find(int _n){n=_n;parent=new int[n];s=new int[n];for(int i=0;is[y] || (s[x]==s[y]&&x