#include<bits/stdc++.h>
#define MAX_N 1001
#define rank dfasfds
using namespace std;
int par[MAX_N],rank[MAX_N];

void init(int n){for(int i=0;i<n;i++)par[i]=i,rank[i]=0;}

int find(int x){
  if(par[x]==x)return x;
  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])par[x]=y;
  else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}
bool same(int x,int y){return find(x)==find(y);}

struct edge{
  int a,b,c;
  bool operator < (edge t) const{return c<t.c;}
};

int n,m;
edge e[10001];
int solve(){
  init(n+1);
  for(int i=0,cnt=0;i<m;i++){
    if(same(e[i].a,e[i].b)) continue;
    unite(e[i].a,e[i].b);
    if(cnt++==(n-1)/2) return e[i].c;
  }
  return 0;
}

int main(){
  while(1){
  cin>>n>>m;
  if(!n&&!m)return 0;
  for(int i=0;i<m;i++)cin>>e[i].a>>e[i].b>>e[i].c;
  sort(e,e+m);
  cout<<solve()<<endl;
  }
  return 0;
}