#include<iostream>
#include<ctime>
#include<cstdio>
#include<cmath>
#include<set>
#include<algorithm>
#include<vector> 
#include<cstring>
#include<string>
#include<map>
#define mp make_pair
#define scn second
#define frs first
#define pb push_back
#define NAME "road"
#define fop freopen(NAME ".in", "r", stdin); freopen(NAME ".out", "w", stdout); 
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pi;
void dout() { cerr << endl; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
  cerr << H << ' ';
  dout(T...);
}
const int INF = 1000000000;
int ROOT;
int S[1000000], n, del[100100];
vector<pi> g[100100];
pi ans;
int st, NS, NL;

void dfs(int v, int s, int l, int p) {
	if (s == NS && l == NL) {
		pi t = mp(v, st);
		if (t.frs > t.scn)
			swap(t.frs, t.scn);
		if (ans == mp(0, 0))
			ans = t;
		ans = min(ans, t);
		return;
	}
	for (int i = 0; i < g[v].size(); ++i) {
		if (g[v][i].frs == p)
			continue;
		dfs(g[v][i].frs, s + g[v][i].scn, l + 1, v);
	}
}


int main(){
	fop;        
	scanf("%d%d%d", &n, &NS, &NL);
	for (int i = 0; i < n - 1; ++i) {
		int a, b, w;
		scanf("%d%d%d", &a, &b, &w);
		g[a].pb(mp(b, w));
		g[b].pb(mp(a, w));
	}	
	for (int i = 1; i <= n; ++i) {
		st = i;
		dfs(i, 0, 0, 0);
	}	
	printf("%d %d", ans.frs, ans.scn);
	cerr << clock() / CLOCKS_PER_SEC << "\n";
	return 0;
}
