int Find(int x)
{
if (tree[x].parent!=x)
{
tree[x].parent=Find(tree[x].parent);
}
return tree[x].parent;
}
void Merge(int a,int b,int p,int q,int d)
{
if(tree[q].depth>tree[p].depth)
tree[p].parent=q;
else
{
tree[q].parent=p;
if(tree[p].depth==tree[q].depth)
tree[p].depth++;
}
}
{
if (tree[x].parent!=x)
{
tree[x].parent=Find(tree[x].parent);
}
return tree[x].parent;
}
void Merge(int a,int b,int p,int q,int d)
{
if(tree[q].depth>tree[p].depth)
tree[p].parent=q;
else
{
tree[q].parent=p;
if(tree[p].depth==tree[q].depth)
tree[p].depth++;
}
}