#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000;
const int INF = 0x3f3f3f3f;
struct node {
  int v, w;
  node *next;
} Edges[MAXN * 2 + 10], *ecnt = Edges, *adj[MAXN + 10];
void addedge(int u, int v, int w) {
  ++ecnt;
  ecnt->v = v;
  ecnt->w = w;
  ecnt->next = adj[u];
  adj[u] = ecnt;
}
pair<int, pair<int, int> > lis[MAXN + 10];
pair<int, int> pri_que[MAXN + 10];
int n, l, r, mlen, mxsum[MAXN + 10], mxcur[MAXN + 10];
int cur_pos[MAXN + 10], sum_pos[MAXN + 10];
int sz[MAXN + 10], global_lim;
bool vis[MAXN + 10];
void dfs_sz(int u, int fa) {
  sz[u] = 1;
  for (node *p = adj[u]; p; p = p->next) {
    if (p->v == fa || vis[p->v]) continue;
    dfs_sz(p->v, u);
    sz[u] += sz[p->v];
  }
}
void dfs_root(int u, int fa, int &rt, int &root, int &cmx) {
  int mx = 0;
  for (node *p = adj[u]; p; p = p->next) {
    if (p->v == fa || vis[p->v]) continue;
    mx = max(mx, sz[p->v]);
  }
  mx = max(mx, sz[rt] - sz[u]);
  if (mx < cmx) {
    cmx = mx;
    root = u;
  }
  for (node *p = adj[u]; p; p = p->next) {
    if (p->v == fa || vis[p->v]) continue;
    dfs_root(p->v, u, rt, root, cmx);
  }
}
int getDep(int u, int fa) {
  int ret = 0;
  for (node *p = adj[u]; p; p = p->next) {
    if (p->v == fa || vis[p->v]) continue;
    ret = max(ret, getDep(p->v, u) + 1);
  }
  return ret + 1;
}
void dfs_sum(int u, int fa, int dsum, int dep = 1) {
  if (dsum > mxcur[dep]) {
    mxcur[dep] = dsum;
    cur_pos[dep] = u;
  }
  for (node *p = adj[u]; p; p = p->next) {
    if (p->v == fa || vis[p->v]) continue;
    dfs_sum(p->v, u, dsum + (p->w >= global_lim ? 1 : -1), dep + 1);
  }
}
vector<pair<int, int> > vec[MAXN + 10];
bool sorted[MAXN + 10];
int tmp[MAXN + 10], current_ans, global_mid;
pair<int, int> res;
void dfs(int u) {
  dfs_sz(u, 0);
  int Root = 0, cmx = 0x3f3f3f3f;
  dfs_root(u, 0, u, Root, cmx);
  u = Root;
  for (node *p = adj[u]; p; p = p->next) {
    if (vis[p->v]) continue;
    vec[u].push_back(make_pair(getDep(p->v, u), p->v));
  }
  sort(vec[u].begin(), vec[u].end());
  sum_pos[0] = u;
  int L = current_ans + 1, R = 0x3f3f3f3f;
  while (L <= R) {
    int mid = (L + R) >> 1;
    global_lim = mid;
    bool ok = false;
    for (node *p = adj[u]; p; p = p->next) {
      if (vis[p->v]) continue;
      tmp[p->v] = p->w >= global_lim ? 1 : -1;
    }
    for (int i = 0; !ok && i < (int)vec[u].size(); i++) {
      for (int j = 1; j <= vec[u][i].first; j++) mxcur[j] = -INF;
      dfs_sum(vec[u][i].second, u, tmp[vec[u][i].second]);
      int L = 0, R = 0, bp = r - min(r, vec[u][i].first);
      for (int j = 0; j < bp; j++) {
        if (mxsum[j] == -INF) break;
        while (R - L && pri_que[L].first < j - mlen) L++;
        while (R - L && pri_que[R - 1].second < mxsum[j]) R--;
        pri_que[R++] = make_pair(j, mxsum[j]);
      }
      for (int j = min(r, vec[u][i].first); j >= 1; j--) {
        while (R - L && pri_que[L].first < r - j - mlen) L++;
        if (mxsum[r - j] != -INF) {
          while (R - L && pri_que[R - 1].second < mxsum[r - j]) R--;
          pri_que[R++] = make_pair(r - j, mxsum[r - j]);
        }
        if (R - L && mxcur[j] + pri_que[L].second >= 0) {
          ok = true;
          res = make_pair(sum_pos[pri_que[L].first], cur_pos[j]);
          break;
        }
      }
      for (int j = 1; j <= vec[u][i].first; j++) {
        if (mxcur[j] > mxsum[j]) {
          mxsum[j] = mxcur[j];
          sum_pos[j] = cur_pos[j];
        }
      }
    }
    if (ok) {
      L = mid + 1;
      current_ans = mid;
    } else
      R = mid - 1;
    if (vec[u].size()) {
      int mxdep = vec[u][vec[u].size() - 1].first;
      for (int i = 1; i <= mxdep; i++) mxsum[i] = -INF;
    }
  }
  vis[u] = true;
  for (node *p = adj[u]; p; p = p->next) {
    if (vis[p->v]) continue;
    dfs(p->v);
  }
}
int main() {
  scanf("%d%d%d", &n, &l, &r);
  mlen = r - l;
  for (int i = 1; i < n; i++) {
    scanf("%d%d%d", &lis[i].second.first, &lis[i].second.second, &lis[i].first);
    addedge(lis[i].second.first, lis[i].second.second, lis[i].first);
    addedge(lis[i].second.second, lis[i].second.first, lis[i].first);
  }
  for (int i = 1; i <= n; i++) mxsum[i] = -INF;
  current_ans = -1;
  dfs(1);
  printf("%d %d\n", res.first, res.second);
  return 0;
}
