#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 222222;
int g[MAX_N], nxt[MAX_N], c[MAX_N], value[MAX_N], ok[MAX_N], nm;
int sc[MAX_N], s[MAX_N], S, root, ss[MAX_N];
int n, L, R;
int m, ansX, ansY, ans, A, B;
int Nb, b[MAX_N];
pair<int, int> xs1[MAX_N], xs2[MAX_N];
int sgl[MAX_N];
int NC, C[MAX_N], D[MAX_N], res[MAX_N];
void addedge(int x, int y, int w) {
  g[nm] = y;
  nxt[nm] = c[x];
  c[x] = nm;
  value[nm] = w;
  ok[nm] = 1;
  nm++;
}
void findroot(int i, int p) {
  s[i] = 1;
  sc[i] = 0;
  for (int k = c[i]; ~k; k = nxt[k]) {
    int j = g[k];
    if (j == p || !ok[k]) continue;
    findroot(j, i);
    s[i] += s[j];
    sc[i] = max(sc[i], s[j]);
  }
  sc[i] = max(sc[i], S - s[i]);
  if (sc[i] < sc[root]) root = i;
}
void findall(int i, int p) {
  for (int k = c[i]; ~k; k = nxt[k]) {
    int j = g[k];
    if (j == p || !ok[k]) continue;
    b[++Nb] = value[k];
    findall(j, i);
  }
}
int maxlen(int i, int p) {
  int mx = 0;
  for (int k = c[i]; ~k; k = nxt[k]) {
    int j = g[k];
    if (j == p || !ok[k]) continue;
    mx = max(mx, maxlen(j, i) + 1);
  }
  return mx;
}
void select(int i, int p, int rs, int dep) {
  if (dep <= R) {
    if (rs > xs2[dep].first) xs2[dep] = make_pair(rs, i);
  }
  for (int k = c[i]; ~k; k = nxt[k]) {
    int j = g[k];
    if (!ok[k] || j == p) continue;
    select(j, i, rs + ((value[k] >= m) ? (1) : (-1)), dep + 1);
  }
}
bool cks(int x) {
  int n1 = 0;
  xs1[0] = make_pair(0, x);
  for (int k = 1; k <= D[C[NC]]; ++k) xs1[k] = make_pair(-1000000000, -1);
  for (int k = 1; k <= NC; ++k) {
    int j = C[k];
    int n2 = D[j];
    for (int i = 1; i <= n2; ++i) xs2[i] = make_pair(-1000000000, -1);
    select(j, x, (value[res[j]] >= m) ? (1) : (-1), 1);
    int p = min(n2, R), l = 1, r = 0;
    for (j = 0; j <= n1; ++j) {
      while (p && p + j >= L) {
        while (l <= r && xs2[p].first >= xs2[sgl[r]].first) --r;
        sgl[++r] = p;
        --p;
      }
      while (l <= r && sgl[l] + j > R) ++l;
      if (l <= r && xs1[j].first + xs2[sgl[l]].first >= 0) {
        A = xs1[j].second, B = xs2[sgl[l]].second;
        return 1;
      }
    }
    for (j = 1; j <= n2; ++j)
      if (xs1[j].first < xs2[j].first) xs1[j] = xs2[j];
    n1 = n2;
  }
  return 0;
}
bool cmp(int x, int y) { return D[x] < D[y]; }
void calc(int x) {
  Nb = 0;
  findall(x, -1);
  sort(b + 1, b + 1 + Nb);
  Nb = unique(b + 1, b + 1 + Nb) - b - 1;
  int l = 0, r = Nb + 1;
  NC = 0;
  for (int k = c[x]; ~k; k = nxt[k]) {
    int j = g[k];
    if (!ok[k]) continue;
    C[++NC] = j;
    res[j] = k;
    D[j] = maxlen(j, x) + 1;
  }
  sort(C + 1, C + 1 + NC, cmp);
  while (l + 1 < r) {
    int mid = (l + r) >> 1;
    m = b[mid];
    if (cks(x))
      l = mid;
    else
      r = mid;
  }
  m = b[l];
  cks(x);
  if (m > ans) {
    ans = m;
    ansX = A;
    ansY = B;
  }
  findroot(x, -1);
  for (int k = c[x]; ~k; k = nxt[k]) {
    int j = g[k];
    if (!ok[k]) continue;
    ss[j] = s[j];
  }
  for (int k = c[x]; ~k; k = nxt[k]) {
    int j = g[k];
    if (!ok[k]) continue;
    ok[k ^ 1] = ok[k] = 0;
    S = ss[j];
    root = 0;
    findroot(j, -1);
    calc(root);
  }
}
int main() {
  scanf("%d%d%d", &n, &L, &R);
  memset(c, -1, sizeof c);
  for (int i = 1; i < n; ++i) {
    int x, y, w;
    scanf("%d%d%d", &x, &y, &w);
    addedge(x, y, w);
    addedge(y, x, w);
  }
  ans = -1;
  s[0] = sc[0] = n + 1;
  S = n;
  root = 0;
  findroot(1, -1);
  calc(root);
  cout << ansX << " " << ansY << endl;
}
