ll@n,@m,@(u--,v--,h)[m]; unionFind d('m',n,1); rsortA(m,h,u,v); rep(i,m){ d(u[i],v[i]); if(d(0)==d(n-1)){ wt(h[i]); exit(0); } } wt("NaN");