#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

struct edge{
	int s, t, c;
	bool operator< (const edge &e) const{
		return c < e.c;
	}
} e[10000];

int par[10001];

int find(int x){
	return x != par[x] ? par[x] = find(par[x]) : x;
}

int main(){
	int n, m;
	while( scanf("%d%d", &n, &m) != EOF && n != 0 ){
		for(int i = 1; i <= n; ++i){
			par[i] = i;
		}
		for(int i = 0; i < m; ++i){
			scanf("%d%d%d", &e[i].s, &e[i].t, &e[i].c);
		}

		sort(e, e + m);

		int u = n / 2;
		for(int i = 0; i < m; ++i){
			int x = find(e[i].s);
			int y = find(e[i].t);
			if( x == y ) continue;
			par[x] = y;

			if( --u == 0 ){
				printf("%d\n", e[i].c);
				break;
			}
		}
	}
}