#include <bits/stdc++.h>
const int mod = 998244353, N = 1e5 + 10, INF = 0x3f3f3f3f;
template <typename T>
inline T read() {
  T x = 0;
  bool f = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    f = ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f ? -x : x;
}
template <typename T>
inline T max(const T& x, const T& y) {
  return x > y ? x : y;
}
template <typename T>
inline T min(const T& x, const T& y) {
  return x < y ? x : y;
}
template <typename T>
inline T abs(const T& x) {
  return x > 0 ? x : -x;
}
inline int Mod(int x) {
  if (x >= mod) {
    return x - mod;
  } else if (x < 0) {
    return x + mod;
  } else {
    return x;
  }
}
template <typename T1, typename T2>
struct pair {
  T1 first;
  T2 second;
  pair(const T1& x = 0, const T2& y = 0) {
    first = x;
    second = y;
  }
  friend pair operator+(const pair& x, const pair& y) {
    return pair(x.first + y.first, x.second + y.second);
  }
  friend pair operator-(const pair& x, const pair& y) {
    return pair(x.first - y.first, x.second - y.second);
  }
  friend bool operator<(const pair& x, const pair& y) {
    return x.first < y.first || (x.first == y.first && x.second < y.second);
  }
  friend bool operator<=(const pair& x, const pair& y) {
    return x.first < y.first || (x.first == y.first && x.second <= y.second);
  }
  friend bool operator>(const pair& x, const pair& y) {
    return x.first > y.first || (x.first == y.first && x.second > y.second);
  }
  friend bool operator>=(const pair& x, const pair& y) {
    return x.first > y.first || (x.first == y.first && x.second >= y.second);
  }
  friend bool operator==(const pair& x, const pair& y) {
    return x.first == y.first && x.second == y.second;
  }
  friend bool operator!=(const pair& x, const pair& y) {
    return x.first != y.first || x.second != y.second;
  }
};
template <typename T1, typename T2>
inline pair<T1, T2> make_pair(const T1& x, const T2& y) {
  return pair<T1, T2>(x, y);
}
template <typename T>
struct stack {
  int top;
  T vals[N];
  bool empty() { return !top; }
  void push(T x) { vals[++top] = x; }
  void pop() {
    if (top > 0) {
      --top;
    }
    return;
  }
  void clear() { top = 0; }
  T TOP() { return top ? vals[top] : T(-1); }
};
inline int ksm(int x, int y) {
  int ret = 1;
  for (; y; y /= 2, x = 1LL * x * x % mod) {
    if (y & 1) {
      ret = 1LL * ret * x % mod;
    }
  }
  return ret;
}
inline int ksc(int x, int y) {
  int ret = 0;
  for (; y; y /= 2, x = Mod(x + x)) {
    if (y & 1) {
      ret = Mod(ret + x);
    }
  }
  return ret;
}
using std::cin;
using std::cout;
using std::endl;
using std::ios;
using std::map;
using std::set;
using std::vector;
int n, l, r, sz[N], mxdep[N], dep[N], val[N], a[N], b[N], path_a[N], path_b[N],
    que[N], hd, tl, t[N];
bool vis[N];
vector<int> son[N];
vector<pair<int, int>> edge[N];
bool cmp(int x, int y) { return mxdep[x] < mxdep[y]; }
int find_root(int u, int fa, int S) {
  int mx = 0;
  sz[u] = 1;
  for (auto& j : edge[u]) {
    if (!vis[j.first] && j.first != fa) {
      int tmp = find_root(j.first, u, S);
      if (tmp) {
        return tmp;
      }
      mx = max(mx, sz[j.first]);
      sz[u] += sz[j.first];
    }
  }
  return max(mx, S - sz[u]) <= S / 2 ? u : 0;
}
void calcsz(int u, int fa) {
  sz[u] = 1;
  for (auto& j : edge[u]) {
    if (!vis[j.first] && j.first != fa) {
      calcsz(j.first, u);
      sz[u] += sz[j.first];
    }
  }
  return;
}
void build_tree(int u) {
  calcsz(u, 0);
  vis[u] = 1;
  for (auto& j : edge[u]) {
    if (!vis[j.first]) {
      int rt = find_root(j.first, 0, sz[j.first]);
      son[u].push_back(rt);
      build_tree(rt);
    }
  }
  return;
}
void dfs(int u, int fa) {
  dep[u] = dep[fa] + 1;
  mxdep[u] = dep[u];
  for (auto& j : edge[u]) {
    if (!vis[j.first] && fa != j.first) {
      dfs(j.first, u);
      mxdep[u] = max(mxdep[u], mxdep[j.first]);
    }
  }
}
int mid;
void dfs_1(int u, int fa) {
  if (val[u] > b[dep[u]]) {
    b[dep[u]] = val[u];
    path_b[dep[u]] = u;
  }
  for (auto& j : edge[u]) {
    if (!vis[j.first] && j.first != fa) {
      dfs_1(j.first, u);
    }
  }
}
void dfs_2(int u, int fa) {
  for (auto& j : edge[u]) {
    if (!vis[j.first] && j.first != fa) {
      val[j.first] = val[u] + (j.second >= mid ? 1 : -1);
      dfs_2(j.first, u);
    }
  }
}
int rt, A, B, ansA, ansB, num, ans;
vector<int> child;
void solve(int u) {
  vis[u] = 1;
  val[u] = 0;
  child.clear();
  dfs(u, 0);
  for (auto& j : edge[u]) {
    if (!vis[j.first]) {
      child.push_back(j.first);
    }
  }
  std::sort(child.begin(), child.end(), cmp);
  int L = ans + 1, R = num;
  while (L <= R) {
    mid = (L + R) / 2;
    bool flag = 0;
    for (int i = 0; i <= mxdep[u]; ++i) {
      a[i] = -INF;
    }
    int hx = 0;
    path_a[0] = u;
    a[0] = 0;
    dfs_2(u, 0);
    for (auto& j : child) {
      for (int i = 0; i <= mxdep[j]; ++i) {
        b[i] = -INF;
      }
      dfs_1(j, 0);
      hd = 1;
      tl = 0;
      for (int i = min(r - 1, hx); i >= l - 1; --i) {
        if (a[i] != -INF) {
          while (hd <= tl && a[que[tl]] <= a[i]) {
            --tl;
          }
          que[++tl] = i;
        }
      }
      for (int i = 1; i <= mxdep[j]; ++i) {
        while (hd <= tl && que[hd] + i > r) {
          ++hd;
        }
        if (l - i <= hx && l >= i && a[l - i] != -INF) {
          while (hd <= tl && a[que[tl]] <= a[l - i]) {
            --tl;
          }
          que[++tl] = l - i;
        }
        if (hd <= tl && b[i] + a[que[hd]] >= 0) {
          flag = 1;
          A = path_a[que[hd]];
          B = path_b[i];
          goto loop;
        }
      }
      for (int i = 1; i <= mxdep[j]; ++i) {
        if (a[i] < b[i]) {
          a[i] = b[i];
          path_a[i] = path_b[i];
        }
      }
      hx = mxdep[j];
    }
  loop:
    if (flag) {
      ans = mid;
      L = mid + 1;
      ansA = A;
      ansB = B;
    } else {
      R = mid - 1;
    }
  }
  for (auto& j : son[u]) {
    solve(j);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << std::fixed << std::setprecision(10);
  cin >> n >> l >> r;
  for (int i = 1, x, y, c; i < n; ++i) {
    cin >> x >> y >> c;
    t[i] = c;
    edge[x].emplace_back(y, c);
    edge[y].emplace_back(x, c);
  }
  std::sort(t + 1, t + n);
  num = std::unique(t + 1, t + 1 + n) - t - 1;
  for (int i = 1; i <= n; ++i) {
    for (auto& j : edge[i]) {
      j.second = std::lower_bound(t + 1, t + 1 + num, j.second) - t;
    }
  }
  dep[0] = -1;
  build_tree(rt = find_root(1, 0, n));
  memset(vis, 0, sizeof vis);
  solve(rt);
  cout << ansA << " " << ansB << endl;
  return 0;
}
