#include <cstdio> #include <iostream> #include <algorithm> using namespace std; const int N=310; const int M=50010; struct edge{int u,v,w;}a[M]; int n,m,p[N],cnt,minn; int cmp(edge x,edge y){return x.w<y.w;} int find(int x){return x==p[x]?x:p[x]=find(p[x]);} void kruskal(){ for(int i=1;i<=cnt;i++){ int x=find(a[i].u),y=find(a[i].v); if(x!=y){ minn=a[i].w; p[x]=y; } } } int main(){ scanf("%d%d",&n,&m); for(int i=1;i<=n;i++)p[i]=i; while(m--){ int u,v,w; scanf("%d%d%d",&u,&v,&w); a[++cnt].u=u; a[cnt].v=v; a[cnt].w=w; } sort(a+1,a+cnt+1,cmp); kruskal(); cout<<n-1<<' '<<minn<<endl; return 0; }