#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, L, R, pos[N], sz, rt, s[N], f[N], q[N], hd, tl, m = N, a1, a2;
int a[N], b[N], az, bz, res, siz, p[N], d[N], dz, ax[N], bx[N], w[N];
bool don[N];
struct edge {
  int y, nex, z;
} g[N * 2];
void init(int x, int y, int z) { g[++sz] = (edge){y, pos[x], z}, pos[x] = sz; }
bool cmp(int x, int y) { return s[x] < s[y]; }
void find(int x, int fa) {
  s[x] = 1;
  for (int i = pos[x]; i; i = g[i].nex) {
    if (g[i].y != fa && !don[g[i].y]) find(g[i].y, x), s[x] += s[g[i].y];
  }
}
void get(int x, int fa) {
  f[x] = 0;
  for (int i = pos[x]; i; i = g[i].nex) {
    if (g[i].y != fa && !don[g[i].y])
      get(g[i].y, x), f[x] = max(f[x], s[g[i].y]);
  }
  f[x] = max(f[x], siz - s[x]);
  if (f[rt] > f[x]) rt = x;
}
void dfs(int x, int fa, int l, int z) {
  bz = max(bz, l);
  if (b[l] < z) b[l] = z, bx[l] = x;
  for (int i = pos[x]; i; i = g[i].nex) {
    if (g[i].y != fa && !don[g[i].y])
      dfs(g[i].y, x, l + 1, z + (g[i].z >= p[m] ? 1 : -1));
  }
}
void check() {
  hd = 1, tl = 0;
  for (int i = min(az, R); i >= L; i--) {
    while (hd <= tl && a[i] > a[q[tl]]) tl--;
    q[++tl] = i;
  }
  for (int i = 1; i <= bz; i++) {
    if (i + az >= L && i <= L) {
      int k = L - i;
      while (hd <= tl && a[k] > a[q[tl]]) tl--;
      q[++tl] = k;
    }
    if (hd <= tl && q[hd] + i > R) hd++;
    if (hd <= tl && a[q[hd]] + b[i] >= 0) {
      a1 = ax[q[hd]], a2 = bx[i];
      res = 1;
    }
  }
  for (int i = 1; i <= bz; i++) {
    if (a[i] < b[i]) a[i] = b[i], ax[i] = bx[i];
    b[i] = -n;
  }
  az = max(az, bz);
  bz = 0;
}
void work(int x) {
  don[x] = 1;
  ax[0] = x;
  for (int i = 1; i <= az; i++) a[i] = -n;
  az = dz = 0;
  for (int i = pos[x]; i; i = g[i].nex)
    if (!don[g[i].y]) {
      find(g[i].y, x);
      d[++dz] = g[i].y, w[g[i].y] = (g[i].z >= p[m] ? 1 : -1);
    }
  sort(d + 1, d + dz + 1, cmp);
  for (int i = 1; i <= dz; i++) {
    dfs(d[i], x, 1, w[d[i]]);
    check();
  }
  for (int i = pos[x]; i; i = g[i].nex) {
    if (don[g[i].y]) continue;
    siz = s[g[i].y], get(g[i].y, rt = 0);
    work(rt);
  }
}
int main() {
  scanf("%d%d%d", &n, &L, &R);
  for (int i = 1; i <= n - 1; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    init(x, y, z), init(y, x, z);
    p[i] = z;
  }
  sort(p + 1, p + n);
  int l = 1, r = n - 1;
  f[0] = n + 1;
  while (l < r || l < m) {
    m = (l + r + 1) >> 1;
    res = 0, siz = n;
    for (int i = 1; i <= n; i++) don[i] = 0, b[i] = -n, a[i] = -n;
    find(1, 0), get(1, rt = 0), work(rt);
    if (res)
      l = m;
    else
      r = m - 1;
  }
  printf("%d %d\n", a1, a2);
  return 0;
}
