import java.io.*;
import java.util.*;

public class road_pk_stupid {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	public String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	class Edge {
		int d;
		long l;

		public Edge(int d, long l) {
			super();
			this.d = d;
			this.l = l;
		}

	}

	public void solve() throws IOException {
		int n = nextInt();
		long l = nextLong();
		int k = nextInt();
		ArrayList<Edge>[] e = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			e[i] = new ArrayList<road_pk_stupid.Edge>();
		}
		for (int i = 0; i < n - 1; i++) {
			int a = nextInt() - 1;
			int b = nextInt() - 1;
			long ll = nextLong();
			e[a].add(new Edge(b, ll));
			e[b].add(new Edge(a, ll));
		}

		for (int i = 0; i < n; i++) {
			int[] d = new int[n];
			long[] dist = new long[n];
			Arrays.fill(d, Integer.MAX_VALUE);
			d[i] = 0;
			dfs(i, d, dist, e);
			for (int j = 0; j < n; j++) {
				if (d[j] == k && dist[j] == l) {
					out.println(i + 1 + " " + (j + 1));
					return;
				}
			}
		}
		out.println("0 0");
	}

	private void dfs(int i, int[] d, long[] dist, ArrayList<Edge>[] e) {
		for (Edge ee : e[i]) {
			if (d[ee.d] == Integer.MAX_VALUE) {
				d[ee.d] = d[i] + 1;
				dist[ee.d] = dist[i] + ee.l;
				dfs(ee.d, d, dist, e);
			}
		}
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			br = new BufferedReader(new FileReader("road.in"));
			out = new PrintWriter("road.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new road_pk_stupid().run();
	}
}