#include<bits/stdc++.h> using namespace std; int n,m; struct edge { int x; int y; int len; }edges[100005]; bool up1(edge a,edge b) // jiegouti anzhao w++++ { return a.len<b.len; } bool down1(edge a,edge b) // jiegouti anzhao w--- { return a.len>b.len; } int parent[100005]; int ffind(int x) { if(x==parent[x]) return x; else return parent[x]=ffind(parent[x]); } int kruskal() { for(int i=1;i<=n;i++) { parent[i]=i; } int ans=0; int num=0; for(int i=1;i<=m;i++) { int a1=ffind(edges[i].x); int a2=ffind(edges[i].y); if(a1!=a2) { ans=ans+edges[i].len; parent[a1]=a2; num++; } } if(num==n-1) return ans; else return 0; } int main() { long long fei[34]; fei[0]=1; fei[1]=1; for(int i=2;i<=33;i++) fei[i]=fei[i-1]+fei[i-2]; int T;cin>>T; for(int o=1;o<=T;o++) { cin>>n>>m; for(int i=1;i<=m;i++) { cin>>edges[i].x>>edges[i].y>>edges[i].len; } printf("Case #%d: ",o); sort(edges+1,edges+m+1,up1); int min1=kruskal(); sort(edges+1,edges+m+1,down1); int max1=kruskal(); //cout<<endl; //cout<<min1<<" "<<max1<<endl; if(min1==0&&max1==0) { cout<<"No"<<endl; } else { int t=0; for(int i=0;i<31;i++) { if(fei[i]<=max1&&fei[i]>=min1) { t=1; break; } } if(t==0) { cout<<"No"<<endl; } if(t==1) { cout<<"Yes"<<endl; } } } return 0; }