#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, LOG = 18;
int n, l, r, T, PEDY;
int ansV, ansU;
pair<pair<int, int>, int> edge[N];
vector<pair<int, int> > G[N];
int num, cen;
int down[N];
bool del[N];
int mark[N];
int val[N];
int deep[N];
int type[N];
int Arr[N], P;
int vec[N], L, R;
vector<int> VAL;
void refresh() {
  for (int i = 0; i < n; i++) G[i].clear();
  for (int i = 0; i < n; i++) {
    del[i] = false;
    mark[i] = -1;
  }
}
int calc(int v, int par = -1) {
  mark[v] = T;
  down[v] = 1;
  for (pair<int, int> u : G[v])
    if (u.first != par && !del[u.first]) down[v] += calc(u.first, v);
  return down[v];
}
int find_cen(int v, int par = -1) {
  for (pair<int, int> u : G[v])
    if (u.first != par && !del[u.first])
      if (down[u.first] * 2 > num) return find_cen(u.first, v);
  return v;
}
void make_tree(int d) {
  refresh();
  for (int i = 0; i < n - 1; i++) {
    G[edge[i].first.first].push_back(
        {edge[i].first.second, (edge[i].second >= d ? +1 : -1)});
    G[edge[i].first.second].push_back(
        {edge[i].first.first, (edge[i].second >= d ? +1 : -1)});
  }
}
void dfs(int v, int par = cen) {
  if (v == cen)
    deep[v] = val[v] = 0;
  else {
    deep[v] = 1 + deep[par];
    type[v] = (par == cen ? v : type[par]);
  }
  if (v != cen)
    if (Arr[deep[v]] == -1 || val[v] > val[Arr[deep[v]]]) Arr[deep[v]] = v;
  for (pair<int, int> u : G[v])
    if (u.first != par && !del[u.first]) {
      val[u.first] = u.second + val[v];
      dfs(u.first, v);
    }
}
bool check(int v, int par) {
  if (r < deep[v]) return false;
  if (l <= deep[v] && 0 <= val[v]) {
    ansV = cen;
    ansU = v;
    return true;
  }
  int len = r - deep[v];
  if (P <= len) len = max(len, r - l + 1);
  if (Arr[len] != -1 && 0 <= val[Arr[len]] + val[v] &&
      type[Arr[len]] != type[v]) {
    ansV = Arr[len];
    ansU = v;
    return true;
  }
  for (pair<int, int> u : G[v])
    if (u.first != par && !del[u.first])
      if (check(u.first, v)) return true;
  return false;
}
void make() {
  P = 1;
  while (Arr[P] != -1) P++;
  L = R = 0;
  for (int i = 1; i < P; i++) {
    while (L < R && val[vec[R - 1]] <= val[Arr[i]]) R--;
    vec[R++] = Arr[i];
    while (L < R && deep[vec[L]] + r - l < i) L++;
    Arr[i] = vec[L];
  }
  if (P <= r - l + 1)
    for (int i = r - l + 1; i < r - l + P; i++) {
      while (L < R && deep[vec[L]] + r - l < i) L++;
      if (L == R) break;
      Arr[i] = vec[L];
    }
  else {
    for (int i = P;; i++) {
      while (L < R && deep[vec[L]] + r - l < i) L++;
      if (L == R) break;
      Arr[i] = vec[L];
    }
  }
}
bool can(int d) {
  make_tree(d);
  int DEL = 0;
  for (T = 0; DEL < n; T++) {
    for (int i = 0; i < n; i++)
      if (mark[i] != T && !del[i]) {
        num = calc(i);
        cen = find_cen(i);
        for (int j = 1; j < P; j++) Arr[j] = -1;
        if (P <= r - l + 1)
          for (int i = r - l + 1; i < r - l + P; i++) Arr[i] = -1;
        else
          for (int i = P; Arr[i] != -1; i++) Arr[i] = -1;
        dfs(cen);
        make();
        for (pair<int, int> u : G[cen])
          if (!del[u.first])
            if (check(u.first, cen)) return true;
        del[cen] = true;
        DEL++;
      }
  }
  return false;
}
int DFS(int v, int par = -1) {
  if (v == ansU) return 0;
  int ans = N + N;
  for (pair<int, int> u : G[v])
    if (u.first != par) ans = min(ans, 1 + DFS(u.first, v));
  return ans;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  fill(Arr, Arr + N, -1);
  cin >> n >> l >> r;
  for (int i = 0; i < n - 1; i++) {
    int v, u, w;
    cin >> v >> u >> w;
    v--, u--;
    edge[i] = {{v, u}, w};
    VAL.push_back(w);
  }
  sort(VAL.begin(), VAL.end());
  VAL.resize(unique(VAL.begin(), VAL.end()) - VAL.begin());
  int s = 0, e = VAL.size();
  while (e - s > 1) {
    int mid = (e + s) >> 1;
    if (can(VAL[mid]))
      s = mid;
    else
      e = mid;
  }
  can(VAL[s]);
  cout << ansV + 1 << " " << ansU + 1 << "\n";
  return 0;
}
