ll@n,@m,@(u,v,h)[m];sortA(m,h,u,v);unionFind U('w',n+1,1);rrep(i,m){U(u[i],v[i]);if(U(1)==U(n)){wt(h[i]);return 0;}}wt("NaN");