#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  bool f = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar()) f = (ch == '-');
  for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48);
  return f ? -x : x;
}
const int N = 1e5 + 7;
int n, L, R, QJ;
int u[N], v[N], val[N];
int head[N], nx[N * 2], to[N * 2], w[N * 2], ec = 1;
inline void add(int a, int b, int c) {
  nx[++ec] = head[a];
  head[a] = ec;
  to[ec] = b;
  w[ec] = c;
}
int flag;
bool been[N];
int sz[N], totsz, mxsz, g;
void getsz(int f, int x) {
  sz[x] = 1;
  for (int i = head[x]; i; i = nx[i]) {
    int t = to[i];
    if (t == f || been[t]) continue;
    getsz(x, t);
    sz[x] += sz[t];
  }
}
void getrt(int f, int x) {
  int maxsz = 0;
  for (int i = head[x]; i; i = nx[i]) {
    int t = to[i];
    if (t == f || been[t]) continue;
    getrt(x, t);
    maxsz = max(maxsz, sz[t]);
  }
  maxsz = max(maxsz, totsz - sz[x]);
  if (maxsz < mxsz) mxsz = maxsz, g = x;
}
int md[N];
int bin[N], dis[N], vdis[N];
void getmd(int f, int x) {
  md[x] = 0;
  dis[x] = -1;
  for (int i = head[x]; i; i = nx[i]) {
    int t = to[i];
    if (t == f || been[t]) continue;
    getmd(x, t);
    md[x] = max(md[x], md[t] + 1);
  }
}
inline bool judmd(int a, int b) { return md[a] < md[b]; }
struct Que {
  int a[N], h, t;
  inline void init() {
    h = 1;
    t = 0;
  }
  inline int front() { return h <= t ? bin[a[h]] : 0; }
  inline void pb(int x) {
    while (h <= t && vdis[bin[a[t]]] < vdis[bin[x]]) --t;
    a[++t] = x;
  }
  inline void pf(int r) {
    if (h <= t && a[h] >= r) ++h;
  }
} Q;
int Ans1, Ans2;
int Tmp[N];
void solve(int x) {
  if (flag) return;
  been[x] = 1;
  md[x] = 0;
  vector<int> vec;
  for (int i = head[x]; i; i = nx[i]) {
    int t = to[i];
    if (been[t]) continue;
    vec.push_back(t);
    getmd(x, t);
    md[x] = max(md[x], md[t] + 1);
    dis[t] = 1;
    vdis[t] = w[i];
  }
  sort(vec.begin(), vec.end(), judmd);
  for (int i = 1; i <= md[x]; ++i) bin[i] = -n;
  dis[x] = 0;
  bin[0] = x;
  int til = 0;
  for (int t : vec) {
    int li = L, ri = R;
    Q.init();
    if (L <= til)
      for (int i = min(R, til); i >= L; --i) Q.pb(i);
    queue<int> q;
    q.push(t);
    for (int i = 1; i <= md[t] + 1; ++i) Tmp[i] = -n;
    while (q.size()) {
      int y = q.front();
      q.pop();
      if (dis[y] <= R) {
        int er = R - dis[y];
        if (ri > er) {
          Q.pf(ri);
          --li, --ri;
          if (li >= 0 && li <= til) Q.pb(li);
        }
      }
      int qf = Q.front();
      if (qf && dis[y] <= R && vdis[y] + vdis[qf] >= 0) {
        flag = 1, Ans1 = y, Ans2 = qf;
        return;
      }
      if (Tmp[dis[y]] < 0 || vdis[Tmp[dis[y]]] < vdis[y]) Tmp[dis[y]] = y;
      for (int i = head[y]; i; i = nx[i]) {
        int r = to[i];
        if (dis[r] == -1 && !been[r])
          dis[r] = dis[y] + 1, vdis[r] = vdis[y] + w[i], q.push(r);
      }
    }
    til = max(til, md[t] + 1);
    for (int j = 1; j <= til; ++j)
      if (bin[j] < 0 || vdis[Tmp[j]] > vdis[bin[j]]) bin[j] = Tmp[j];
  }
  for (int i = head[x]; i; i = nx[i]) {
    int t = to[i];
    if (been[t]) continue;
    getsz(x, t);
    totsz = mxsz = sz[t];
    getrt(x, t);
    solve(g);
  }
}
inline bool check(int mid) {
  ec = 1;
  memset(head, 0, sizeof(head));
  for (int i = 1; i < n; ++i) {
    add(u[i], v[i], val[i] >= mid ? 1 : -1);
    add(v[i], u[i], val[i] >= mid ? 1 : -1);
  }
  memset(been, 0, sizeof(been));
  flag = 0;
  getsz(0, 1);
  totsz = mxsz = sz[1];
  getrt(0, 1);
  solve(g);
  return flag;
}
int main() {
  n = read();
  L = read();
  R = read();
  for (int i = 1; i < n; ++i)
    u[i] = read(), v[i] = read(), val[i] = read(), QJ = max(QJ, val[i]);
  int lg = 0, rg = QJ;
  if (QJ == 0) return puts("1 2"), 0;
  while (lg < rg) {
    int mid = (lg + rg + 1) >> 1;
    if (check(mid))
      lg = mid;
    else
      rg = mid - 1;
  }
  printf("%d %d\n", Ans1, Ans2);
  return 0;
}
