#include #include #include using namespace std; const int M=1010; int cas,n,m,i,f[M],A[M],ans[M]; char s[10]; struct edge{int x,y,w,col;}a[M]; bool cmp(edge a,edge b){return a.w