#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
const int INF = 0x3f3f3f3f;
int n, m, l, r, cnt, front, tail, en, nowr;
int dist[maxn], weight[maxn], size[maxn], f[maxn], q[maxn], belong[maxn],
    num[maxn], sum[maxn];
bool vis[maxn];
struct solution {
  int v, p1, p2;
} ans, nowans;
struct place {
  int v, p;
  place() {}
  place(int a, int b) {
    v = a;
    p = b;
  }
} g[maxn];
struct priority_queue {
  place q[maxn];
  int front, tail;
  void clear() {
    front = 1;
    tail = 0;
  }
  void push(place v) {
    while (front <= tail && v.v >= q[tail].v) tail--;
    tail++;
    q[tail] = v;
  }
  place query(int p) {
    while (front <= tail && q[front].p < p) front++;
    if (front <= tail)
      return q[front];
    else
      return place(-INF, -1);
  }
} que;
struct edge {
  int e, d;
  edge *next;
} * v[maxn], ed[maxn << 1];
void add_edge(int s, int e, int d) {
  en++;
  ed[en].next = v[s];
  v[s] = ed + en;
  v[s]->e = e;
  v[s]->d = d;
}
int get_mid(int now) {
  cnt++;
  f[now] = 0;
  belong[now] = cnt;
  front = tail = 1;
  q[front] = now;
  while (front <= tail) {
    int now = q[front];
    front++;
    size[now] = weight[now] = 0;
    for (edge *e = v[now]; e; e = e->next)
      if (!vis[e->e] && belong[e->e] != cnt) {
        f[e->e] = now;
        belong[e->e] = cnt;
        tail++;
        q[tail] = e->e;
      }
  }
  for (int a = tail; a >= 1; a--) {
    int now = q[a];
    size[now]++;
    size[f[now]] += size[now];
    weight[f[now]] = max(weight[f[now]], size[now]);
    weight[now] = max(weight[now], tail - size[now]);
  }
  int p = q[1];
  for (int a = 2; a <= tail; a++)
    if (weight[q[a]] < weight[p]) p = q[a];
  size[0] = size[now];
  nowr = min(r, tail);
  return p;
}
void calc(int now, int nowdis) {
  front = tail = 1;
  q[1] = now;
  cnt++;
  belong[now] = cnt;
  while (front <= tail) {
    int now = q[front];
    front++;
    for (edge *e = v[now]; e; e = e->next)
      if (!vis[e->e] && belong[e->e] != cnt) {
        num[e->e] = num[now] + 1;
        sum[e->e] = sum[now] + (e->d >= nowdis ? 1 : -1);
        belong[e->e] = cnt;
        tail++;
        q[tail] = e->e;
      }
  }
}
bool check(int now, int nowdis) {
  for (int a = 0; a <= size[0]; a++) g[a].v = -INF;
  g[0].v = 0;
  g[0].p = now;
  nowans.v = -INF;
  for (edge *e = v[now]; e; e = e->next)
    if (!vis[e->e]) {
      num[e->e] = 1;
      sum[e->e] = e->d >= nowdis ? 1 : -1;
      calc(e->e, nowdis);
      int tmp = tail;
      while (num[q[tail]] > nowr) tail--;
      place ansv;
      ansv.v = -INF;
      for (int a = 0; a + num[q[tail]] <= nowr; a++)
        if (g[a].v > ansv.v) ansv = g[a];
      int remain = nowr - num[q[tail]];
      while (tail && num[q[tail]] >= l) {
        while (remain + 1 + num[q[tail]] <= nowr) {
          remain++;
          if (g[remain].v > ansv.v) ansv = g[remain];
        }
        if (sum[q[tail]] + ansv.v > nowans.v) {
          nowans.v = sum[q[tail]] + ansv.v;
          nowans.p1 = q[tail];
          nowans.p2 = ansv.p;
        }
        tail--;
      }
      if (tail) {
        que.clear();
        for (int a = l - num[q[tail]]; a <= nowr - num[q[tail]]; a++)
          que.push(place(g[a].v, a));
        remain = nowr - num[q[tail]];
        while (tail) {
          while (remain + 1 + num[q[tail]] <= nowr) {
            remain++;
            que.push(place(g[remain].v, remain));
          }
          ansv.p = que.query(l - num[q[tail]]).p;
          ansv.v = g[ansv.p].v;
          if (sum[q[tail]] + ansv.v > nowans.v) {
            nowans.v = sum[q[tail]] + ansv.v;
            nowans.p1 = q[tail];
            nowans.p2 = g[ansv.p].p;
          }
          tail--;
        }
      }
      for (int a = 1; a <= tmp; a++)
        if (sum[q[a]] > g[num[q[a]]].v) {
          g[num[q[a]]].v = sum[q[a]];
          g[num[q[a]]].p = q[a];
        }
    }
  return nowans.v >= 0;
}
void dfs(int now) {
  int p = get_mid(now);
  vis[p] = true;
  if (l > nowr) return;
  int lv = 1, rv = m + 1;
  while (lv + 1 != rv) {
    int m = (lv + rv) >> 1;
    if (check(p, dist[m]))
      lv = m;
    else
      rv = m;
  }
  check(p, dist[lv]);
  if (dist[lv] > ans.v) {
    ans = nowans;
    ans.v = dist[lv];
  }
  for (edge *e = v[p]; e; e = e->next)
    if (!vis[e->e]) dfs(e->e);
}
int main() {
  scanf("%d%d%d", &n, &l, &r);
  for (int a = 1; a < n; a++) {
    int s, e, d;
    scanf("%d%d%d", &s, &e, &d);
    add_edge(s, e, d);
    add_edge(e, s, d);
    dist[a] = d;
  }
  m = n - 1;
  sort(dist + 1, dist + m + 1);
  m = unique(dist + 1, dist + m + 1) - dist - 1;
  ans.v = -INF;
  dfs(1);
  printf("%d %d\n", min(ans.p1, ans.p2), max(ans.p1, ans.p2));
  return 0;
}
