#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int INF = 2147483647;
struct EDGE {
  int to, len, c;
};
int n, L, R, A[N], B[N], C[N];
int cvc, vc[N];
vector<EDGE> g[N];
int ans1, ans2;
int maxdep, subtree_size[N], dep[N], sum[N];
int cvs, vs[N], endid[N];
bool centroid[N];
int pw2, zkw[N * 4];
void initzkw(int sz) {
  for (pw2 = 1; pw2 < sz; pw2 <<= 1)
    ;
  for (int i = 1; i < (pw2 << 1); i++) zkw[i] = 0;
}
void update(int i, int u) {
  int val = sum[u];
  for (i += pw2; i > 0; i >>= 1)
    if (val > sum[zkw[i]]) zkw[i] = u;
}
int query(int l, int r) {
  int ans = 0;
  for (l += pw2, r += pw2; l < r; l >>= 1, r >>= 1) {
    if (l & 1) {
      if (sum[zkw[l]] > sum[ans]) ans = zkw[l];
      l++;
    }
    if (r & 1) {
      r--;
      if (sum[zkw[r]] > sum[ans]) ans = zkw[r];
    }
  }
  return ans;
}
int compute_subtree_size(int u, int lst) {
  subtree_size[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].to;
    if (v == lst || centroid[v]) continue;
    subtree_size[u] += compute_subtree_size(v, u);
  }
  return subtree_size[u];
}
pair<int, int> get_centroid(int u, int lst, int sz) {
  pair<int, int> res = make_pair(INF, 0);
  int sm = 1, mx = 0;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].to;
    if (v == lst || centroid[v]) continue;
    res = min(res, get_centroid(v, u, sz));
    mx = max(mx, subtree_size[v]);
    sm += subtree_size[v];
  }
  mx = max(mx, sz - sm);
  res = min(res, make_pair(mx, u));
  return res;
}
void initdfs(int u, int lst, int lim, int D) {
  dep[u] = D;
  maxdep = max(maxdep, D);
  vs[++cvs] = u;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].to;
    if (v == lst || centroid[v]) continue;
    if (g[u][i].c < lim)
      sum[v] = sum[u] - 1;
    else
      sum[v] = sum[u] + 1;
    initdfs(v, u, lim, D + 1);
  }
  endid[u] = cvs;
}
bool solve(int u, int lim) {
  compute_subtree_size(u, 0);
  int s = get_centroid(u, 0, subtree_size[u]).second;
  centroid[s] = true;
  for (int i = 0; i < g[s].size(); i++) {
    int v = g[s][i].to;
    if (centroid[v]) continue;
    if (solve(v, lim)) return true;
  }
  maxdep = 0;
  sum[s] = 0;
  cvs = 0;
  initdfs(s, 0, lim, 0);
  initzkw(maxdep + 1);
  update(dep[s], s);
  for (int i = 2, j; i <= cvs; i = endid[vs[i]] + 1) {
    for (j = i; j <= endid[vs[i]]; j++) {
      int u = vs[j];
      int rL = max(0, L - dep[u]), rR = min(maxdep, R - dep[u]);
      if (rR < 0) continue;
      rR++;
      int v = query(rL, rR);
      if (!v) continue;
      if (sum[u] + sum[v] >= 0) {
        ans1 = u, ans2 = v;
        return true;
      }
    }
    for (j = i; j <= endid[vs[i]]; j++) {
      int u = vs[j];
      update(dep[u], u);
    }
  }
  centroid[s] = false;
  return false;
}
int main() {
  scanf("%d%d%d", &n, &L, &R);
  for (int i = 1; i < n; i++) {
    scanf("%d%d%d", &A[i], &B[i], &C[i]);
    vc[cvc++] = C[i];
  }
  sort(vc, vc + cvc);
  cvc = unique(vc, vc + cvc) - vc;
  EDGE ztr;
  for (int i = 1; i < n; i++) {
    C[i] = lower_bound(vc, vc + cvc, C[i]) - vc + 1;
    ztr.c = C[i];
    ztr.to = B[i];
    g[A[i]].push_back(ztr);
    ztr.to = A[i];
    g[B[i]].push_back(ztr);
  }
  int lo, hi, mid;
  lo = 1;
  hi = cvc;
  sum[0] = -INF;
  while (lo < hi) {
    mid = (lo + hi + 1) >> 1;
    ans1 = ans2 = 0;
    memset(centroid, false, sizeof(centroid));
    if (solve(1, mid))
      lo = mid;
    else
      hi = mid - 1;
  }
  solve(1, lo);
  printf("%d %d\n", ans1, ans2);
  return 0;
}
