#include <bits/stdc++.h>
const int MAXN = 1e5 + 5;
inline char nc() {
  static char buf[1000000 + 3], *p1 = buf + 1000000 + 3,
                                *p2 = buf + 1000000 + 3;
  if (p1 == p2) {
    p1 = buf;
    p2 = buf + fread(buf, 1, 1000000 + 3, stdin);
    if (p1 == p2) return -1;
  }
  return *p1++;
}
template <typename T>
inline void read(T &x) {
  x = 0;
  int flag = 0;
  char ch = nc();
  while (!isdigit(ch)) {
    if (ch == '-') flag = 1;
    ch = nc();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ '0');
    ch = nc();
  }
  if (flag) x = -x;
}
struct Edge {
  int u, v, w;
} e[MAXN];
int n, L, R;
std::vector<std::pair<int, int> > G[MAXN];
int mx[MAXN], sz[MAXN], rt;
bool vis[MAXN];
int sx = -1, sy = -1;
inline void getroot(int v, int fa = 0) {
  sz[v] = 1;
  mx[v] = 0;
  for (auto x : G[v]) {
    if (vis[x.first] || x.first == fa) continue;
    getroot(x.first, v);
    sz[v] += sz[x.first];
    mx[v] = std::max(mx[v], sz[x.first]);
  }
  mx[v] = std::max(mx[v], mx[0] - sz[v]);
  if (mx[v] < mx[rt]) rt = v;
}
std::vector<std::pair<int, int> > S[MAXN];
inline void dfs(int v, int rt, int dep, int dis, int fa = 0) {
  while (((int)S[rt].size()) < dep + 1) S[rt].emplace_back(-1e9, -1);
  S[rt][dep] = std::max(S[rt][dep], std::make_pair(dis, v));
  for (auto x : G[v]) {
    if (x.first == fa || vis[x.first]) continue;
    dfs(x.first, rt, dep + 1, dis + x.second, v);
  }
}
bool flag = 0;
std::vector<int> rr[MAXN];
inline void work(int v) {
  vis[v] = 1;
  std::vector<int> vec;
  for (auto x : G[v]) {
    if (vis[x.first]) continue;
    S[x.first].clear();
    dfs(x.first, x.first, 1, x.second);
    for (int i = 1; i <= ((int)S[x.first].size()) - 1; ++i)
      if (L <= i && i <= R && S[x.first][i].first >= 0) {
        sx = v;
        sy = S[x.first][i].second;
      }
    vec.emplace_back(x.first);
  }
  if (vec.empty()) return;
  std::sort(vec.begin(), vec.end(), [&](int x, int y) {
    return ((int)S[x].size()) < ((int)S[y].size());
  });
  std::vector<std::pair<int, int> > now = S[vec[0]];
  auto merge = [&](std::vector<std::pair<int, int> > &A,
                   std::vector<std::pair<int, int> > &B) {
    std::deque<int> q;
    int nr = -1;
    for (int i = ((int)B.size()) - 1; i >= 1; --i) {
      int ll = std::max(1, L - i), rr = std::min(((int)A.size()) - 1, R - i);
      if (ll > rr) continue;
      while (nr != rr) {
        ++nr;
        while (!q.empty() && A[q.back()].first <= A[nr].first) q.pop_back();
        q.push_back(nr);
      }
      while (!q.empty() && q.front() < ll) q.pop_front();
      if (q.empty()) continue;
      if (A[q[0]].first + B[i].first >= 0) {
        sx = B[i].second;
        sy = A[q[0]].second;
      }
    }
    for (int i = 0; i <= ((int)A.size()) - 1; ++i) A[i] = std::max(A[i], B[i]);
    for (int i = ((int)A.size()); i <= ((int)B.size()) - 1; ++i)
      A.emplace_back(B[i]);
  };
  for (int i = 1; i <= ((int)vec.size()) - 1; ++i) merge(now, S[vec[i]]);
  int t = 0;
  for (auto x : G[v]) {
    if (vis[x.first]) continue;
    if (!flag) {
      mx[rt = 0] = sz[x.first];
      getroot(x.first);
      rr[v].emplace_back(rt);
    }
    work(rr[v][t++]);
  }
}
int RR;
inline bool chk(int k) {
  for (int i = 1; i <= n - 1; ++i)
    [&](int u, int v, int w) {
      G[u].emplace_back(v, w), G[v].emplace_back(u, w);
    }(e[i].u, e[i].v, e[i].w >= k ? 1 : -1);
  sx = sy = -1;
  if (!RR) {
    mx[rt = 0] = n;
    getroot(1);
    RR = rt;
  }
  work(RR);
  for (int i = 1; i <= n; ++i) G[i].clear(), vis[i] = 0;
  flag = 1;
  return sx != -1;
}
int main() {
  read(n);
  read(L);
  read(R);
  for (int i = 1; i <= n - 1; ++i) read(e[i].u), read(e[i].v), read(e[i].w);
  int l = 0, r = 1e9, ans = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (chk(mid))
      ans = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  chk(ans);
  printf("%d %d\n", sx, sy);
  return 0;
}
