#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

class union_find {
private:
	vector<int> uf;
public:
	union_find(int n):uf(n, -1) {}

	int find(int x) {
		return uf[x] < 0 ? x : uf[x] = find(uf[x]);
	}

	bool unite(int a, int b) {
		a = find(a);
		b = find(b);

		if(a == b) return false;

		if(uf[a] > uf[b]) {
			swap(a, b);
		}
		else if(uf[a] == uf[b]) {
			--uf[a];
		}

		uf[b] = a;
		return true;
	}
};

struct edge {
	int u, v;
	int cost;
	edge(int u, int v, int c):u(u), v(v), cost(c){}
	bool operator<(const edge &e) const {
		return cost < e.cost;
	}
};

int calc(int n, vector<edge> &edges) {
	sort(edges.begin(), edges.end());

	int cnt = 0;
	union_find uf(n);
	for(const auto &e : edges) {
		if(uf.unite(e.u, e.v) && ++cnt == n / 2) return e.cost;
	}
}

int main() {
	for(int n, m; cin >> n >> m && n;) {
		vector<edge> edges;
		edges.reserve(m);
		for(int i = 0; i < m; ++i) {
			int s, t, c;
			cin >> s >> t >> c;
			edges.emplace_back(s - 1, t - 1, c);
		}
		cout << calc(n, edges) << endl;
	}

	return EXIT_SUCCESS;
}