#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, inf = 0x3f3f3f3f;
int h[N], cnt, nxt[N], to[N], e[N], siz[N], w[N];
int n, m, L, R, a, b, c, ts, rs, rt, vis[N], s[N];
int ans, ansu, ansv;
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int in() {
  int x = 0;
  char ch = nc();
  while (ch < '0' || ch > '9') ch = nc();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = nc();
  return x;
}
void add(int u, int v, int w) {
  ++cnt;
  nxt[cnt] = h[u];
  h[u] = cnt;
  to[cnt] = v;
  e[cnt] = w;
}
void getrt(int u, int fa) {
  int ns = 0;
  siz[u] = 1;
  for (int i = h[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == fa || vis[v]) continue;
    getrt(v, u);
    siz[u] += siz[v];
    if (siz[v] > ns) ns = siz[v];
  }
  if (ts - siz[u] > ns) ns = ts - siz[u];
  if (rs > ns) rs = ns, rt = u;
}
int cu, cv, q[N], sq[N], qu[N], squ[N], ld, nd;
int tmp[N], tmpu[N], mid, top;
void dfs(int u, int fa, int d, int x) {
  if (tmp[d] < x) tmp[d] = x, tmpu[d] = u;
  if (nd < d) nd = d;
  for (int i = h[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == fa || vis[v]) continue;
    if (e[i] >= w[mid])
      dfs(v, u, d + 1, x + 1);
    else
      dfs(v, u, d + 1, x - 1);
  }
}
bool check(int u) {
  ld = 0;
  sq[0] = 0;
  squ[0] = u;
  for (int i = 1; i <= top; ++i) {
    int v = to[s[i]];
    for (int j = 1; j <= siz[v]; ++j) tmp[j] = -inf;
    nd = 0;
    if (e[s[i]] >= w[mid])
      dfs(v, u, 1, 1);
    else
      dfs(v, u, 1, -1);
    int l = 1, r = 0, lb = ld, rb = ld + 1;
    for (int j = 1; j <= nd; ++j) {
      while (rb > 0 && rb > L - j) {
        --rb;
        while (l <= r && sq[q[r]] < sq[rb]) --r;
        q[++r] = rb;
      }
      while (lb >= 0 && lb > R - j) {
        --lb;
        while (l <= r && q[l] > lb) ++l;
      }
      if (l <= r && sq[q[l]] + tmp[j] >= 0) {
        cu = squ[q[l]];
        cv = tmpu[j];
        return 1;
      }
    }
    while (ld < nd) sq[++ld] = -inf;
    for (int j = 1; j <= nd; ++j)
      if (sq[j] < tmp[j]) sq[j] = tmp[j], squ[j] = tmpu[j];
  }
  return 0;
}
bool cmp(int a, int b) { return siz[to[a]] < siz[to[b]]; }
void solve(int u) {
  int ns = ts;
  top = 0;
  for (int i = h[u]; i; i = nxt[i]) {
    int v = to[i];
    if (vis[v]) continue;
    if (siz[v] > siz[u]) siz[v] = ns - siz[u];
    s[++top] = i;
  }
  sort(s + 1, s + 1 + top, cmp);
  int l = 1, r = m, now = 0, nu, nv;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (check(u))
      l = mid + 1, now = mid, nu = cu, nv = cv;
    else
      r = mid - 1;
  }
  if (now > ans) ans = now, ansu = nu, ansv = nv;
  vis[u] = 1;
  for (int i = h[u]; i; i = nxt[i]) {
    int v = to[i];
    if (vis[v]) continue;
    rs = ts = siz[v];
    getrt(v, 0);
    solve(rt);
  }
}
int main() {
  n = in();
  L = in();
  R = in();
  for (int i = 1; i < n; ++i) {
    a = in();
    b = in();
    c = in();
    add(a, b, c);
    add(b, a, c);
    w[i] = c;
  }
  rs = ts = n;
  sort(w + 1, w + n);
  m = unique(w + 1, w + n) - w - 1;
  getrt(1, 0);
  solve(rt);
  printf("%d %d\n", ansu, ansv);
  return 0;
}
