#include<iostream>
#include<algorithm>
using namespace std;
struct node{
int a,b,c;
};
node zuf[40005];
int fa[40005],siz[40005];
bool cmp(node x,node y)
{
return x.c>y.c;
}
int Find(int x)
{
if(fa[x]==x)return x;
else fa[x]=Find(fa[x]);
}
int main()
{
int n,m;
cin>>n>>m;
for(int p=1;p<=m;p++)
cin>>zuf[p].a>>zuf[p].b>>zuf[p].c;
sort(zuf+1,zuf+m+1,cmp);
for(int p=1;p<=2*n;p++)fa[p]=p;
for(int p=1;p<=m;p++)
{
int u=Find(zuf[p].a),v=Find(zuf[p].b);//
if(u==v)
{
cout<<zuf[p].c<<endl;
return 0;
}
fa[u]=Find(zuf[p].b+n);
fa[v]=Find(zuf[p].a+n);
}
}
感觉思路没错啊QAQ,为什么连样例都过不了求助QAQ