#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) y) { return (f)(begin(y), end(y), ## __VA_ARGS__); })(x)
using namespace std;
struct disjoint_sets {
    vector<int> xs;
    explicit disjoint_sets(size_t n) : xs(n, -1) {}
    bool is_root(int i) { return xs[i] < 0; }
    int find_root(int i) { return is_root(i) ? i : (xs[i] = find_root(xs[i])); }
    int set_size(int i) { return - xs[find_root(i)]; }
    int union_sets(int i, int j) {
        i = find_root(i); j = find_root(j);
        if (i != j) {
            if (set_size(i) < set_size(j)) swap(i,j);
            xs[i] += xs[j];
            xs[j] = i;
        }
        return i;
    }
    bool is_same(int i, int j) { return find_root(i) == find_root(j); }
};
struct edge_t { int s, t, c; };
bool operator < (edge_t const & a, edge_t const & b) { return a.c < b.c; } // strict weak ordering
int main() {
    while (true) {
        int n, m; cin >> n >> m;
        if (n == 0 and m == 0) break;
        vector<edge_t> es(m);
        repeat (i,m) {
            cin >> es[i].s >> es[i].t >> es[i].c;
            -- es[i].s;
            -- es[i].t;
        }
        whole(sort, es);
        disjoint_sets t(n);
        vector<int> acc;
        for (edge_t e : es) {
            if (not t.is_same(e.s, e.t)) {
                t.union_sets(e.s, e.t);
                acc.push_back(e.c);
            }
        }
        whole(sort, acc);
        double ans = (n-1) % 2 == 0 ? (acc[(n-1)/2] + acc[(n-1)/2+1]) / 2.0 : acc[(n-1)/2];
        cout << ans << endl;
    }
    return 0;
}