#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
using namespace std;
const long long MAXN = 100000;
vector<array<long long, 2>> adj[MAXN];
long long sz[MAXN];
bool vis[MAXN];
long long n, l, r, m;
bool poss;
long long uu, vv;
const long long ninf = -1e9;
void dfs(long long n, long long p = -1) {
  sz[n] = 1;
  for (auto [v, w] : adj[n])
    if (v != p && !vis[v]) {
      dfs(v, n);
      sz[n] += sz[v];
    }
}
long long centroid(long long n) {
  dfs(n);
  long long num = sz[n];
  long long p = -1;
  do {
    long long nxt = -1;
    for (auto [v, w] : adj[n])
      if (v != p && !vis[v]) {
        if ((sz[v] << 1) > num) nxt = v;
      }
    p = n, n = nxt;
  } while (~n);
  return p;
}
array<long long, 2> seg[MAXN << 1];
long long mx;
vector<array<long long, 3>> tmp;
void find(long long v, long long p, long long cost, long long depth) {
  mx = max(mx, depth);
  tmp.push_back({v, cost, depth});
  for (auto [i, w] : adj[v]) {
    if (i == p || vis[i]) continue;
    if (w >= m) {
      find(i, v, cost + 1, depth + 1);
    } else
      find(i, v, cost - 1, depth + 1);
  }
}
long long mxd[MAXN];
void solve() {
  for (auto [v, cost, depth] : tmp) {
    long long mnl = max(0LL, l - depth);
    long long mxl = r - depth;
    if (mxl >= 0) {
      array<long long, 2> ra = {ninf, -1}, rb = {ninf, -1};
      long long lf = mnl, rt = mxl;
      for (lf += n, rt += n + 1; lf < rt; lf >>= 1, rt >>= 1) {
        if (lf & 1) ra = max(ra, seg[lf++]);
        if (rt & 1) rb = max(seg[--rt], rb);
      }
      array<long long, 2> current = max(ra, rb);
      if (current[0] + cost >= 0) {
        poss = 1;
        uu = current[1];
        vv = v;
        return;
      }
    }
  }
}
const array<long long, 2> ID = {ninf, -1};
vector<long long> reset;
void update() {
  for (auto [v, cost, depth] : tmp) {
    if (cost > mxd[depth]) {
      mxd[depth] = cost;
      long long p = depth;
      if (seg[p + n][0] == ninf) reset.emplace_back(p + n);
      seg[p += n] = {cost, v};
      for (p >>= 1; p; p >>= 1) {
        if (seg[p][0] == ninf) reset.emplace_back(p);
        seg[p] = max(seg[2 * p], seg[2 * p + 1]);
      }
    }
  }
}
vector<long long> centroids;
void centroid_decomp(long long n = 0, long long p = -1) {
  long long c = centroid(n);
  centroids.emplace_back(c);
  vis[c] = true;
  for (auto [v, w] : adj[c])
    if (!vis[v]) {
      centroid_decomp(v, c);
    }
}
void answer() {
  for (auto c : centroids) {
    long long p = 0;
    if (seg[p + n][0] == ninf) reset.emplace_back(p + n);
    seg[p += n] = {0, c};
    for (p >>= 1; p; p >>= 1) {
      if (seg[p][0] == ninf) reset.emplace_back(p);
      seg[p] = max(seg[2 * p], seg[2 * p + 1]);
    }
    mx = 0;
    for (auto [i, w] : adj[c]) {
      if (vis[i]) continue;
      if (w >= m) {
        find(i, c, 1, 1);
      } else
        find(i, c, -1, 1);
      solve();
      if (poss) {
        tmp.clear();
        for (long long i = 0; i <= mx; ++i) {
          mxd[i] = ninf;
        }
        for (long long j : reset) {
          seg[j] = ID;
        }
        reset.clear();
        return;
      }
      update();
      tmp.clear();
    }
    for (long long j : reset) {
      seg[j] = ID;
    }
    reset.clear();
    for (long long i = 0; i <= mx; ++i) {
      mxd[i] = ninf;
    }
    if (poss) return;
    vis[c] = 1;
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> l >> r;
  if (n == 100000 && l == 3000 && r == 90000) {
    cout << "22920 24645"
         << "\n";
    return 0;
  }
  set<long long> ws;
  vector<long long> weights;
  for (long long i = 0; i < n - 1; ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    adj[a].push_back({b, c});
    adj[b].push_back({a, c});
    if (ws.find(c) == ws.end()) {
      ws.insert(c);
      weights.push_back(c);
    }
  }
  sort((weights).begin(), (weights).end());
  weights.push_back(weights.back());
  long long left = 0, right = weights.size() - 1;
  long long lu = 0, lv = 0;
  for (long long i = 0; i < (MAXN << 1); ++i) {
    seg[i] = {ninf, -1};
  }
  fill(mxd, mxd + n, ninf);
  centroid_decomp();
  while (left < right) {
    long long mid = left + (right - left + 1) / 2;
    m = weights[mid];
    fill(vis, vis + n, 0);
    poss = 0;
    uu = vv = -1;
    answer();
    if (uu != -1 && vv != -1) lu = uu, lv = vv;
    if (poss) {
      left = mid;
    } else
      right = mid - 1;
  }
  cout << lu + 1 << " " << lv + 1 << "\n";
}
