#include <bits/stdc++.h>

using namespace std;

int par[1001];

void init(int n)
{
    memset(par, -1, sizeof(par));
}

int find(int x)
{
    if (par[x] < 0) return (x);
    return (par[x] = find(par[x]));
}

void merge(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y) return;
    
    if (-par[x] < -par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
}

bool same(int x, int y)
{
    return (find(x) == find(y));
}


int main()
{
    int n, m;
    
    while (scanf("%d %d", &n, &m) && n){
        vector<pair<int, pair<int, int> > > es(m);
        
        for (int i = 0; i < m; i++){
            int a, b, c;
            scanf("%d %d %d", &a, &b, &c);
            es[i] = make_pair(c, make_pair(a, b));
        }
        
        sort(es.begin(), es.end());
        
        init(n + 1);
        int ec = 0;
        int i = 0;
        while (ec != n - 1 && i != m){
            if (!same(es[i].second.first, es[i].second.second)){
                merge(es[i].second.first, es[i].second.second);
                if (++ec == n / 2){
                    printf("%d\n", es[i].first);
                    break;
                }
            }
            i++;
        }
    }
    
    return (0);
}