#include "bits/stdc++.h"

using namespace std;

struct Edge{
    int from,to,cost;
    Edge(int from,int to,int cost): from(from), to(to), cost(cost){}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool operator < (const Edge &e, const Edge &f){
    return e.cost < f.cost;
}

struct UF {
	vector<int> data;
	UF(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool find(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,m;
    while(cin>>n>>m,n){
        UF uf(n);
        Edges es;
        vector<int> ans;
        for(int i=0;i<m;i++){
            int st,gt,c;cin>>st>>gt>>c;
            st--;gt--;
            es.push_back(Edge(st,gt,c));
        }
        sort(es.begin(),es.end());
        for(int i=0;i<m;i++){
            int st=es[i].from,gt=es[i].to;
            if(!uf.find(st,gt)){
                uf.unite(st,gt);
                ans.push_back(es[i].cost);
            }
        }
        cout<<ans[(n-1)/2]<<endl;
    }
}
