#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 5, INF = numeric_limits<int>::max() / 2;
int n, L, R;
int median;
bool good;
vector<pair<int, int> > adj[maxN];
bool vis[maxN];
int sz[maxN], h[maxN], mxdep[maxN];
int bestAns = -1;
pair<int, int> constMx[maxN], Mx[maxN];
pair<int, int> ans;
void getSz(int u, int p) {
  sz[u] = 1;
  for (auto T : adj[u]) {
    int v = T.first;
    if (v != p and !vis[v]) {
      getSz(v, u);
      sz[u] += sz[v];
    }
  }
}
int centroid(int u, int p, int r) {
  for (auto T : adj[u]) {
    int v = T.first;
    if (v != p and !vis[v] and 2 * sz[v] > sz[r]) return centroid(v, u, r);
  }
  return u;
}
void dfs(int u, int p) {
  mxdep[u] = h[u];
  for (auto T : adj[u]) {
    int v = T.first;
    if (v != p and !vis[v]) {
      h[v] = h[u] + 1;
      dfs(v, u);
      mxdep[u] = max(mxdep[u], mxdep[v]);
    }
  }
}
void dfs(int u, int p, int cost) {
  Mx[h[u]] = max(Mx[h[u]], {cost, u});
  for (auto T : adj[u]) {
    int v = T.first, w = T.second;
    if (v != p and !vis[v]) {
      dfs(v, u, cost + (w >= median ? 1 : -1));
    }
  }
}
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  return mxdep[a.first] < mxdep[b.first];
}
void Solve(int u) {
  getSz(u, u);
  u = centroid(u, u, u);
  vis[u] = true;
  h[u] = 0;
  dfs(u, u);
  sort((adj[u]).begin(), (adj[u]).end(), cmp);
  pair<int, int> curAns;
  int low = -1, high = 1e9;
  while (low < high) {
    median = (low + high + 1) >> 1;
    good = false;
    for (int i = 1; i <= mxdep[u]; i++) constMx[i] = {-INF, -1};
    constMx[0] = {0, u};
    int preMx = 0;
    for (auto T : adj[u]) {
      int v = T.first, w = T.second;
      if (vis[v]) continue;
      for (int i = 0; i <= mxdep[v]; i++) Mx[i] = {-INF, -1};
      dfs(v, u, (w >= median ? 1 : -1));
      deque<int> dq;
      for (int i = 0; i <= min(mxdep[v], R); i++) {
        while (preMx >= 0 and preMx >= L - i) {
          while (!dq.empty() and
                 constMx[dq.front()].first < constMx[preMx].first)
            dq.pop_front();
          dq.push_back(preMx--);
        }
        while (!dq.empty() and dq.front() > R - i) dq.pop_front();
        if (!dq.empty() and constMx[dq.front()].first + Mx[i].first >= 0) {
          good = true;
          curAns = {constMx[dq.front()].second, Mx[i].second};
        }
      }
      for (int i = 0; i <= mxdep[v]; i++) constMx[i] = max(constMx[i], Mx[i]);
      preMx = mxdep[v];
    }
    if (good)
      low = median;
    else
      high = median - 1;
  }
  if (bestAns < low) {
    bestAns = low;
    ans = curAns;
  }
  for (auto T : adj[u]) {
    int v = T.first;
    if (!vis[v]) Solve(v);
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> L >> R;
  for (int i = 1; i < n; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
  }
  for (int i = 1; i <= n; i++) constMx[i] = Mx[i] = {-INF, -1};
  Solve(1);
  cout << ans.first << ' ' << ans.second;
}
