#include <bits/stdc++.h>
using namespace std;

typedef struct Edge{
    int w, s, t;
    
    bool operator < (const Edge r)const{
        return w < r.w;
    };
}Edge;

class UnionFind {
    vector<int> par;
    int cnt;
public:
    UnionFind(int size_) : par(size_, -1), cnt(size_) { }
    void unite(int x, int y){
        if ((x = find(x)) != (y = find(y))) {
            if (par[y] < par[x]) swap(x, y);
            par[x] += par[y]; par[y] = x; cnt--;
        }
    }
    bool same(int x, int y){ return find(x) == find(y); }
    int find(int x){ return par[x] < 0 ? x : par[x] = find(par[x]); }
    int size(int x){ return -par[find(x)]; }
    int size(){ return cnt; }
};

int N, M;

int main(){
    while(cin >> N >> M, N|M){
        auto uf = UnionFind(N);
        
        vector<Edge> edges;
        for(int i=0; i<M; i++){
            int s, t, w;
            cin >> s >> t >> w; s--; t--;
            edges.push_back({w, s, t});
        }
        sort(edges.begin(), edges.end());
        
        int cnt = 0;
        for(auto &e: edges){
            if(!uf.same(e.s, e.t)){
                uf.unite(e.s, e.t);
                cnt++;
            }
            if(cnt == N/2){
                cout << e.w << endl;
                break;
            }
        }
    }
    
    return 0;
}