#include <iostream> #include <cstring> #include <vector> using namespace std; int w[10005],v[10005],a[10001]; int findpy(int x){ if(x==a[x]){ return a[x]; } return a[x]=findpy(a[x]); } int main(){ int T; cin>>T; while(T--){ int n,m,c,x,y; cin>>n>>m>...