#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;

struct UnionFindTree {
    vector<int> par;
    vector<int> rank;
    vector<int> siz;

    void init(int n) {
        par.resize(n);
        rank.resize(n);
        siz.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        siz[x] += siz[y];
    }
    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        x = find(x);
        return siz[x];
    }
};

int n, m;
vector<P3> es;

int kruskal(){
    sort(es.begin(), es.end());
    UnionFindTree g;
    g.init(n);
    vector<int> ls;
    for(auto e : es){
        int u = e.second.first, v = e.second.second;
        if(!g.is_same(u, v)){
            g.unite(u,v);
            ls.push_back(e.first);
        }
    }
    sort(ls.begin(), ls.end());
    return ls[n/2-1];
}

int main() {
    while(cin >> n >> m, n){
        es.clear();
        for(int i=0;i<m;i++){
            int a, b, c;
            cin >> a >> b >> c;
            a--; b--;
            es.push_back({c,{a,b}});
        }
        cout << kruskal() << endl;
    }
    return 0;
}

