#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m;int w;
int f[199999];int q[199999],ff;
int find(int x)
{
if(f[x]==x) return x;
int fx=find(f[x]);
q[x]+=q[f[x]];
return f[x]=fx;
}
int main()
{
scanf("%d",&w);
while(w--)
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
f[i]=i,q[i]=0;ff=0;
for(int i=1;i<=m;i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
if(ff==1) continue;
int fx=find(x);
int fy=find(y);
if(fx==fy)
{
// printf("%d %d\n",q[y]-q[x],z);
if(q[y]-q[x]!=z) printf("Bessie is blind.\n"),ff=1;
}
else f[fy]=fx,q[fy]=-q[y]+q[x]+z;
}
if(ff==0) printf("Bessie's eyes are good\n");
}
}
奶牛身高
最新推荐文章于 2020-04-30 15:11:40 发布