#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int inf = 1000000009;
int rd() {
  char c = getchar();
  int t = 0, f = 1;
  while (!isdigit(c)) f = (c == '-') ? -1 : 1, c = getchar();
  while (isdigit(c)) t = t * 10 + c - 48, c = getchar();
  return t * f;
}
void wt(int x) {
  if (x < 0) {
    putchar('-');
    wt(-x);
    return;
  }
  if (x > 9) wt(x / 10);
  putchar(x % 10 + 48);
  return;
}
vector<pair<int, int> > e[N];
long long dis[N];
pair<int, int> stk[N], g[N];
map<pair<int, int>, int> Map;
int head[N], cnt, sz[N], f[N], vis[N], Max, stkdep, Maxdep;
int top, l, r, Q[N], lim, sum, rt, n, Hash[N], x, y, Ans, Len, keynode, p1, p2;
struct Edge {
  int to, nxt, val;
} E[N << 1];
void Link(int u, int v, int w) {
  E[++cnt] = (Edge){v, head[u], w};
  head[u] = cnt;
  E[++cnt] = (Edge){u, head[v], w};
  head[v] = cnt;
}
void getrt(int x, int fa) {
  sz[x] = 1, f[x] = 0;
  for (int y, i = head[x]; i; i = E[i].nxt)
    if ((y = E[i].to) != fa && !vis[y]) {
      getrt(y, x);
      sz[x] += sz[y];
      f[x] = max(f[x], sz[y]);
    }
  f[x] = max(f[x], sum - sz[x]);
  if (f[x] < f[rt]) rt = x;
  return;
}
void getdis(int x, int fa, int dep, int val) {
  if (dep > r) return;
  stkdep = max(stkdep, dep);
  stk[dep] = max(stk[dep], make_pair(val, x));
  for (int y, i = head[x]; i; i = E[i].nxt)
    if ((y = E[i].to) != fa && !vis[y])
      getdis(y, x, dep + 1, val + (E[i].val >= lim ? 1 : -1));
}
void tour(int x, int fa, int dep, int val) {
  if (dep > r) return;
  Maxdep = max(Maxdep, dep);
  g[dep] = max(g[dep], make_pair(val, x));
  for (int y, i = head[x]; i; i = E[i].nxt)
    if ((y = E[i].to) != fa && !vis[y])
      tour(y, x, dep + 1, val + (E[i].val >= lim ? 1 : -1));
}
bool calc() {
  int L = max(l - stkdep, 0), R = min(r - stkdep, Maxdep), h = 1, t = 0;
  for (int i = ((int)L); i <= ((int)R); i++)
    if (i <= Maxdep) {
      while (h <= t && g[Q[t]] < g[i]) t--;
      Q[++t] = i;
    }
  if (!t) return 0;
  for (int i = ((int)stkdep); i >= ((int)1); i--) {
    if (stk[i].first + g[Q[h]].first >= 0) {
      Len = i + Q[h];
      p1 = stk[i].second;
      p2 = g[Q[h]].second;
      return 1;
    }
    if (L == Maxdep) return 0;
    if (Q[h] == L && l - i >= 0) h++;
    if (l - i >= 0) L++;
    if (R < Maxdep) {
      R++;
      while (h <= t && g[Q[t]] < g[R]) t--;
      Q[++t] = R;
    }
  }
  return 0;
}
bool solve(int x) {
  vis[x] = 1;
  Maxdep = 0;
  g[0] = make_pair(0, x);
  for (int y, i = head[x]; i; i = E[i].nxt)
    if (!vis[y = E[i].to]) {
      stkdep = 0;
      getdis(y, x, 1, E[i].val >= lim ? 1 : -1);
      if (calc()) {
        keynode = x;
        return 1;
      }
      for (int j = ((int)0); j <= ((int)stkdep); j++)
        stk[j] = make_pair(-inf, -inf);
      tour(y, x, 1, E[i].val >= lim ? 1 : -1);
    }
  for (int i = ((int)1); i <= ((int)Maxdep); i++) g[i] = make_pair(-inf, -inf);
  for (int y, i = head[x]; i; i = E[i].nxt)
    if (!vis[y = E[i].to]) {
      sum = sz[y], rt = 0;
      getrt(y, x);
      if (solve(rt)) return 1;
    }
  return 0;
}
bool chk(int x) {
  for (int i = ((int)0); i <= ((int)n); i++)
    vis[i] = 0, stk[i] = g[i] = make_pair(-inf, -inf);
  sum = n, rt = 0;
  lim = x;
  getrt(1, -1);
  return solve(rt);
}
int main() {
  n = rd(), l = rd(), r = rd();
  f[0] = inf;
  for (int i = ((int)1); i <= ((int)n - 1); i++) {
    x = rd(), y = rd(), Link(x, y, Hash[i] = rd());
    Map[make_pair(x, y)] = Hash[i], Map[make_pair(y, x)] = Hash[i];
  }
  sort(Hash + 1, Hash + n);
  for (int L = 1, R = n - 1; L <= R;) {
    int mid = L + R >> 1;
    if (chk(Hash[mid]))
      L = (Ans = mid) + 1;
    else
      R = mid - 1;
  }
  Ans = Hash[Ans];
  printf("%d %d\n", p1, p2);
  return 0;
}
