#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5;
const int inf = 1000000000 + 10;
int hide[N], sz[N], par[N], h[N], hp[N], ew[N], vec[N], seg[4 * N], L, R, ptr,
    mx_med = -1, pth, nxt;
vector<pair<int, int> > adj[N];
vector<int> W;
void reset(int l = 0, int r = ptr + 1, int id = 1) {
  seg[id] = -inf;
  if (r - l == 1) return;
  int mid = (l + r) >> 1;
  reset(l, mid, (id << 1));
  reset(mid, r, (id << 1 | 1));
}
void modify(int p, int val, int l = 0, int r = ptr + 1, int id = 1) {
  if (r - l == 1) {
    seg[id] = max(seg[id], val);
    return;
  }
  int mid = (l + r) >> 1;
  if (p < mid)
    modify(p, val, l, mid, (id << 1));
  else
    modify(p, val, mid, r, (id << 1 | 1));
  seg[id] = max(seg[(id << 1)], seg[(id << 1 | 1)]);
}
int get(int l, int r, int s = 0, int e = ptr + 1, int id = 1) {
  if (e <= l || r <= s) return -inf;
  if (l <= s && e <= r) return seg[id];
  int mid = (s + e) >> 1;
  return max(get(l, r, s, mid, (id << 1)), get(l, r, mid, e, (id << 1 | 1)));
}
void preDFS(int v, int p = 0) {
  sz[v] = 1;
  for (pair<int, int> e : adj[v])
    if (e.first != p && !hide[e.first])
      preDFS(e.first, v), sz[v] += sz[e.first];
}
void DFS(int v, int p = 0) {
  par[v] = p;
  for (pair<int, int> e : adj[v]) {
    if (e.first != p && !hide[e.first]) {
      vec[ptr++] = e.first;
      h[e.first] = h[v] + 1;
      ew[e.first] = e.second;
      DFS(e.first, v);
    }
  }
}
void pthDFS(int v, int p = 0, int H = 0, int Hp = 0) {
  if (L <= H && H <= R && 0 <= Hp) nxt = v;
  for (pair<int, int> e : adj[v])
    if (e.first != p)
      pthDFS(e.first, v, H + 1, Hp + (mx_med <= e.second ? 1 : -1));
}
int findCentroid(int v, int t, int p = 0) {
  bool f = true;
  while (f) {
    f = false;
    for (pair<int, int> e : adj[v])
      if (e.first != p && !hide[e.first] && t < 2 * sz[e.first]) {
        p = v;
        v = e.first;
        f = true;
        break;
      }
  }
  return v;
}
void solve(int v) {
  preDFS(v);
  v = findCentroid(v, sz[v]);
  ptr = 0;
  h[v] = 0;
  DFS(v, 0);
  hp[v] = 0;
  int l = -1, r = ((int)(W.size()));
  while (1 < r - l) {
    int mid = (l + r) >> 1;
    for (int i = 0; i < ptr; i++)
      hp[vec[i]] = hp[par[vec[i]]] + (W[mid] <= ew[vec[i]] ? 1 : -1);
    reset();
    modify(0, 0);
    int last = 0, find = 0;
    for (int i = 0; i < ptr; i++) {
      int u = vec[i];
      if (h[u] == 1) {
        for (int j = last; j < i; j++) modify(h[vec[j]], hp[vec[j]]);
        last = i;
      }
      int lp = max(0, L - h[u]);
      int rp = max(0, R - h[u] + 1);
      if (0 <= hp[u] + get(lp, rp)) {
        find = 1;
        if (mx_med < W[mid]) {
          mx_med = W[mid];
          pth = u;
        }
        break;
      }
    }
    if (find)
      l = mid;
    else
      r = mid;
  }
  hide[v] = 1;
  for (pair<int, int> e : adj[v])
    if (!hide[e.first]) solve(e.first);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n >> L >> R;
  for (int i = 1; i < n; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    adj[u].push_back(make_pair(v, w));
    adj[v].push_back(make_pair(u, w));
    W.push_back(w);
  }
  sort(W.begin(), W.end());
  W.resize(unique(W.begin(), W.end()) - W.begin());
  solve(1);
  pthDFS(pth);
  cout << pth << ' ' << nxt;
  return 0;
}
