#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

typedef tuple<ll,ll,ll> e;

vector<ll> uft;

ll parent(ll a){
    if(uft[a]==a){return a;}
    return uft[a]=parent(uft[a]);
}

int main(){
    ll n,m;
    while(cin>>n>>m){
        if(n==0){break;}
    uft.resize(n);
    for(int i=0;i<n;i++){uft[i]=i;}
    priority_queue<e,vector<e>,greater<e>> Q;
    for(int i=0;i<m;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--; b--;
        Q.push(make_tuple(c,a,b));
    }
    ll ans=-1;
    ll count=0;
    while(!Q.empty()){
        e W=Q.top(); Q.pop();
        if(parent(get<1>(W))!=parent(get<2>(W))){
            count++;
            if(count==n/2){ans=get<0>(W);}
            uft[parent(get<1>(W))]=parent(get<2>(W));
        }
    }
    cout<<ans<<endl;
    }
    
    
    return 0;
}

