#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 make_size(int v, int p) {
	S[v] = 1;
    for (int i = 0; i < g[v].size(); ++i) {
    	if (del[g[v][i].frs] || p == g[v][i].frs)
    		continue;
    	S[v] += make_size(g[v][i].frs, v); 
    }
	return S[v];
}

int find_start(int v, int p) {	
	for (int i = 0; i < g[v].size(); ++i) {
		if (del[g[v][i].frs] || g[v][i].frs == p)
			continue;
		if (S[g[v][i].frs] >= S[ROOT]/2)
			return find_start(g[v][i].frs, v);	
	}
	return v;	
}
map<pi, int> have;
int NS, NL;
vector<pair<pi, int> > nw;

void dfs(int v, int sum, int l, int p) {
	nw.pb(mp(mp(sum, l), v));
	int w = have[mp(NS - sum, NL - l)];
	if (w != 0) { 
		pi t = mp(v, w);
		if (v > w)
			swap(t.frs, t.scn);
		if (ans == mp(0, 0))
			ans = t;  
		ans = min(ans, t);
	}	
	for (int i = 0; i < g[v].size(); ++i) {
		if (del[g[v][i].frs] || g[v][i].frs == p)
			continue;
	    dfs(g[v][i].frs, sum + g[v][i].scn, l + 1, v);	
	}
}

void get(int v) {		
	make_size(v, - 1);
	ROOT = v;
	int st = find_start(v, -1);
	//cerr << st << " ";
	v = -INF;
	del[st] = 1;
	for (int i = 0; i < g[st].size(); ++i) {
	    if (del[g[st][i].frs])
	    	continue;
	    ROOT = g[st][i].frs;
	    dfs(g[st][i].frs, g[st][i].scn, 1, st);		
		for (int j = 0; j < nw.size(); ++j) { 
			if (have[nw[j].frs] > 0) 
				have[nw[j].frs] = min(have[nw[j].frs], nw[j].scn);
			else
				have[nw[j].frs] = nw[j].scn;
		}		
		nw.clear();
	}
	if (have[mp(NS, NL)] != 0) {
		pi t = mp(st, have[mp(NS, NL)]);
		if (t.frs > t.scn)
			swap(t.frs, t.scn);  
		if (ans == mp(0, 0))
			ans = t;  		
		ans = min(ans, t);		
	}
	have.clear();
	for (int i = 0; i < g[st].size(); ++i) { 
	    if (del[g[st][i].frs])
	    	continue;	    
	    get(g[st][i].frs);		
	}
		
}

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));
	}	
	if (NL == 0 && NS == 0) {
		printf("1 1");
		return 0;
	}
	if (NL == 0) {
		printf("0 0");
		return 0;	
	}
	get(1);
	printf("%d %d", ans.frs, ans.scn);
	cerr << clock() / CLOCKS_PER_SEC << "\n";
	return 0;
}
