#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  if (flag) x = -x;
}
using namespace std;
const int inf = 987654321;
inline void MAX(int &a, int b) {
  if (b > a) a = b;
}
int n;
int ans, X, Y, Mx;
struct edge {
  int nxt, to, val;
} e[101000 << 1];
int head[101000], ecnt;
inline void addedge(int from, int to, int val) {
  e[++ecnt] = (edge){head[from], to, val};
  head[from] = ecnt;
}
int L, R;
int siz[101000], mxSiz, Siz, root;
bool vis[101000];
void find_root(int cur, int faa) {
  siz[cur] = 1;
  int mx = 0;
  for (register int i = head[cur]; i; i = e[i].nxt) {
    int to = e[i].to;
    if (vis[to] || to == faa) continue;
    find_root(to, cur);
    siz[cur] += siz[to];
    MAX(mx, siz[to]);
  }
  MAX(mx, Siz - siz[cur]);
  if (mx < mxSiz) mxSiz = mx, root = cur;
}
int pv[101000], d[101000];
int dfs_dep(int cur, int faa, int nwd) {
  int res = nwd;
  for (register int i = head[cur]; i; i = e[i].nxt) {
    int to = e[i].to;
    if (to == faa || vis[to]) continue;
    MAX(res, dfs_dep(to, cur, nwd + 1));
  }
  return res;
}
int arr[101000], atot;
bool cmp(const int x, const int y) { return d[x] < d[y]; }
pair<int, int> h[101000], H[101000];
int stk[101000], st, ed, htot, Htot;
void dfs_h(int cur, int faa, int nwd, int nwv, int t) {
  if (nwv > h[nwd].first) h[nwd] = make_pair(nwv, cur);
  for (register int i = head[cur]; i; i = e[i].nxt) {
    int to = e[i].to;
    if (to == faa || vis[to]) continue;
    dfs_h(to, cur, nwd + 1, nwv + (e[i].val >= t ? 1 : -1), t);
  }
}
inline bool calc(int t) {
  htot = Htot = 0;
  for (register int i = 1; i <= atot; ++i) {
    dfs_h(arr[i], 0, 1, pv[arr[i]] >= t ? 1 : -1, t);
    st = ed = 0;
    --ed;
    int l = L, r = R;
    for (register int j = min(r, Htot); j >= l; --j) {
      while (st <= ed && H[stk[ed]] <= H[j]) --ed;
      stk[++ed] = j;
    }
    htot = d[arr[i]];
    for (register int j = 1; j <= htot; ++j) {
      if (st <= ed && stk[st] == r) ++st;
      --r;
      if (r < 0) break;
      --l;
      if (l <= Htot && l >= 0) {
        while (st <= ed && H[stk[ed]] <= H[l]) --ed;
        stk[++ed] = l;
      }
      if (st <= ed && H[stk[st]].first + h[j].first >= 0) {
        ans = t;
        X = H[stk[st]].second;
        Y = h[j].second;
        for (register int p = 1; p <= Htot; ++p) H[p] = make_pair(-inf, -1);
        for (register int p = 1; p <= htot; ++p) h[p] = make_pair(-inf, -1);
        return true;
      }
    }
    for (register int i = 1; i <= htot; ++i) {
      if (h[i] > H[i]) H[i] = h[i];
      h[i].first = -inf;
      h[i].second = -1;
    }
    Htot = htot;
  }
  for (register int i = 1; i <= Htot; ++i) H[i].first = -inf;
  return false;
}
void dfs(int cur) {
  vis[cur] = true;
  atot = 0;
  for (register int i = head[cur]; i; i = e[i].nxt) {
    int to = e[i].to;
    if (vis[to]) continue;
    d[to] = dfs_dep(to, cur, 1);
    pv[to] = e[i].val;
    arr[++atot] = to;
  }
  sort(arr + 1, arr + 1 + atot, cmp);
  H[0] = make_pair(0, cur);
  int l = ans + 1, r = Mx;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (calc(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  for (register int i = head[cur]; i; i = e[i].nxt) {
    int to = e[i].to;
    if (vis[to]) continue;
    Siz = siz[to], mxSiz = Siz;
    find_root(to, cur);
    dfs(root);
  }
}
int main() {
  memset(h, 0xc0, sizeof(h));
  memset(H, 0xc0, sizeof(H));
  read(n), read(L), read(R);
  for (register int i = 1; i < n; ++i) {
    int u, v, w;
    read(u), read(v), read(w);
    addedge(u, v, w), addedge(v, u, w);
    MAX(Mx, w);
  }
  Siz = n, mxSiz = n;
  find_root(1, 0);
  ans = -1;
  dfs(root);
  printf("%d %d\n", X, Y);
  return 0;
}
