#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005, INF = 0x3f3f3f3f;
int n, L, R, xx, yy, zz, ll, rr, mid, ct, totl, last[MAXN], pre[2 * MAXN],
    oth[2 * MAXN], len[2 * MAXN], val[2 * MAXN], dis[MAXN], de[MAXN],
    size[MAXN], z[MAXN], mxd[MAXN], q[MAXN], a[MAXN], b[MAXN];
bool vis[MAXN];
pair<int, int> ret_pair, ans;
inline int read() {
  int x = 0;
  char c = getchar();
  while (c < '0') c = getchar();
  while (c >= '0') x = x * 10 + c - '0', c = getchar();
  return x;
}
inline void conn(int a, int b, int c) {
  pre[++totl] = last[a];
  last[a] = totl;
  oth[totl] = b;
  len[totl] = c;
}
void getct(int x, int fx, int t_size) {
  size[x] = 1;
  int mx = 0;
  for (int p = last[x]; p; p = pre[p]) {
    int r = oth[p];
    if (r != fx && !vis[r]) {
      getct(r, x, t_size);
      size[x] += size[r];
      mx = max(mx, size[r]);
    }
  }
  mx = max(mx, t_size - size[x]);
  if (2 * mx <= t_size) ct = x;
}
void getde(int x, int fx) {
  mxd[x] = 0;
  for (int p = last[x]; p; p = pre[p]) {
    int r = oth[p];
    if (!vis[r] && r != fx) {
      de[r] = de[x] + 1;
      getde(r, x);
      mxd[x] = max(mxd[x], mxd[r] + 1);
    }
  }
}
void dfs(int x, int fx) {
  size[x] = 1;
  if (dis[x] > dis[b[de[x]]]) b[de[x]] = x;
  for (int p = last[x]; p; p = pre[p]) {
    int r = oth[p];
    if (!vis[r] && r != fx) {
      dis[r] = dis[x] + val[p];
      dfs(r, x);
      size[x] += size[r];
    }
  }
}
inline bool cmp(int x, int y) { return mxd[x] < mxd[y]; }
bool calc(int x) {
  de[x] = 0;
  getde(x, 0);
  z[0] = 0;
  for (int p = last[x]; p; p = pre[p])
    if (!vis[oth[p]]) {
      z[++z[0]] = oth[p];
      dis[oth[p]] = val[p];
    }
  sort(z + 1, z + z[0] + 1, cmp);
  for (int i = 0; i <= mxd[x]; ++i) a[i] = 0;
  dis[x] = 0;
  a[0] = x;
  for (int i = 1; i <= z[0]; ++i) {
    int r = z[i];
    mxd[r]++;
    for (int i = 0; i <= mxd[r]; ++i) b[i] = 0;
    dfs(r, x);
    int he = 1, ta = 0;
    for (int i = min(mxd[r], R); i >= L + 1; --i)
      if (a[i]) {
        while (he <= ta && dis[a[i]] > dis[q[ta]]) ta--;
        q[++ta] = a[i];
      }
    for (int i = 0; i <= mxd[r]; ++i) {
      if (i > R) break;
      while (he <= ta && de[q[he]] > R - i) he++;
      if (L - i >= 0 && L - i <= mxd[x] && a[L - i]) {
        while (he <= ta && dis[a[L - i]] > dis[q[ta]]) ta--;
        q[++ta] = a[L - i];
      }
      if (b[i] && he <= ta && dis[b[i]] + dis[q[he]] >= 0) {
        ret_pair = make_pair(q[he], b[i]);
        return 1;
      }
    }
    for (int i = 0; i <= mxd[r]; ++i)
      if (dis[b[i]] > dis[a[i]]) a[i] = b[i];
  }
  return 0;
}
bool work(int x, int t_size) {
  getct(x, 0, t_size);
  int rt = ct;
  vis[rt] = 1;
  if (calc(rt)) return 1;
  for (int p = last[rt]; p; p = pre[p]) {
    int r = oth[p];
    if (!vis[r]) {
      if (work(r, size[r])) return 1;
    }
  }
  return 0;
}
bool check(int mid) {
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= totl; ++i) val[i] = (len[i] < mid ? -1 : 1);
  return work(1, n);
}
int main() {
  n = read();
  L = read();
  R = read();
  for (int i = 1; i <= n - 1; ++i) {
    xx = read();
    yy = read();
    zz = read();
    rr = max(rr, zz);
    conn(xx, yy, zz);
    conn(yy, xx, zz);
  }
  dis[0] = -INF;
  while (ll <= rr) {
    mid = (ll + rr) >> 1;
    if (check(mid)) {
      ans = ret_pair, ll = mid + 1;
    } else
      rr = mid - 1;
  }
  printf("%d %d\n", ans.first, ans.second);
  return 0;
}
