for(int i=1;i<=n;i++){ if(p[i]==find(1)) res++; } for(int i=1;i<=m;i++){ if(p1[i]==find1(1)) cnt++; }