// 2007アジア地区予選F : Slim Span #include #include #include #include using namespace std; const int INF = 1000000000; int root[101]; int getRoot(int v){ return ~root[v] ? root[v] = getRoot(root[v]) : v; } int main(){ int n, m; ifstream cin("F.in"); while(cin >> n >> m, n){ int a, b, w; vector< pair > > vp; for(int i=0;i> a >> b >> w; vp.push_back(make_pair(w, make_pair(a, b))); } sort(vp.begin(), vp.end()); int start = 0, res = INF; while(start < m){ int cnt = 0, curw = vp[start].first; memset(root, -1, sizeof(root)); for(int i=start;i