#include <bits/stdc++.h>
using namespace std;
struct Seg_T {
  int n;
  pair<int, int> dat[8 * 100010];
  void init(int _n) {
    for (n = 1; n < _n; n *= 2)
      ;
    for (int i = 1; i < 4 * n; i++) dat[i] = make_pair(-1000000000, -1);
  }
  void ins(int p, pair<int, int> v) {
    p += n + 1;
    for (; p >= 1 && v > dat[p]; p /= 2) dat[p] = v;
  }
  pair<int, int> rmq(int st, int ed) {
    if (st > ed) return make_pair(-1000000000, -1);
    st += n;
    ed += n + 2;
    pair<int, int> r = make_pair(-1000000000, -1);
    while (st ^ ed ^ 1) {
      if (~st & 1) r = max(r, dat[st ^ 1]);
      if (ed & 1) r = max(r, dat[ed ^ 1]);
      st >>= 1;
      ed >>= 1;
    }
    return r;
  }
} seg;
struct E {
  int to, val;
  E() {}
  E(int _to, int _val) : to(_to), val(_val) {}
};
int n, lb, ub, st, ed, ans = -1, gap, vis[100010], who[100010], dis[100010],
                       val[100010], fa[100010], sz[100010], nn, q[100010], fr,
                       bk, big[100010];
vector<E> e[100010];
int get_root(int p) {
  nn = fr = bk = 0;
  q[bk++] = p;
  fa[p] = -1;
  while (fr != bk) {
    who[nn++] = p = q[fr++];
    for (__typeof((e[p]).begin()) it = (e[p]).begin(); it != (e[p]).end(); it++)
      if (!vis[it->to] && it->to != fa[p]) {
        fa[it->to] = p;
        q[bk++] = it->to;
      }
  }
  int w = p, sml = 1000000000;
  for (int i = nn - 1; i >= 0; i--) {
    sz[p = who[i]] = 1;
    for (__typeof((e[p]).begin()) it = (e[p]).begin(); it != (e[p]).end(); it++)
      if (!vis[it->to] && it->to != fa[p]) sz[p] += sz[it->to];
    int bl = nn - sz[p];
    for (__typeof((e[p]).begin()) it = (e[p]).begin(); it != (e[p]).end(); it++)
      if (!vis[it->to] && it->to != fa[p]) bl = max(bl, sz[it->to]);
    if (bl < sml) sml = bl, w = p;
  }
  return w;
}
void dfs(int p, int f, int d, int v) {
  who[nn] = p;
  dis[nn] = d;
  val[nn] = v;
  nn++;
  for (__typeof((e[p]).begin()) it = (e[p]).begin(); it != (e[p]).end(); it++)
    if (!vis[it->to] && it->to != f)
      dfs(it->to, p, d + 1, v + (it->val >= gap ? 1 : -1));
}
bool chk(int p, int sn) {
  seg.init(sn + 5);
  seg.ins(0, make_pair(0, p));
  for (__typeof((e[p]).begin()) it = (e[p]).begin(); it != (e[p]).end(); it++)
    if (!vis[it->to]) {
      nn = 0;
      dfs(it->to, p, 1, it->val >= gap ? 1 : -1);
      for (int i = 0; i < nn; i++)
        if (ub - dis[i] >= 0) {
          pair<int, int> now =
              seg.rmq(max(lb - dis[i], 0), min(ub - dis[i], sn));
          if (val[i] + now.first >= 0) {
            st = who[i];
            ed = now.second;
            return 1;
          }
        }
      for (int i = 0; i < nn; i++) seg.ins(dis[i], make_pair(val[i], who[i]));
    }
  return 0;
}
void go(int p) {
  vis[p = get_root(p)] = 1;
  nn = 0;
  dfs(p, 0, 0, 0);
  int sn = *max_element(dis, dis + nn), L = ans, R = 1000000000;
  while (L != R) {
    gap = (L + R + 1) / 2;
    if (chk(p, sn))
      ans = L = gap;
    else
      R = gap - 1;
  }
  for (__typeof((e[p]).begin()) it = (e[p]).begin(); it != (e[p]).end(); it++)
    if (!vis[it->to]) go(it->to);
}
int main() {
  scanf("%d%d%d", &n, &lb, &ub);
  for (int i = 1; i < n; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    e[a].push_back(E(b, c));
    e[b].push_back(E(a, c));
  }
  go(1);
  printf("%d %d\n", st, ed);
  return 0;
}
