#include <bits/stdc++.h>
using namespace std;
int n, cnt, L, R, ans1, ans2;
int sorted[100010];
bool flag[100010];
struct Edge {
  int v, c;
  Edge() {}
  Edge(int v, int c) : v(v), c(c) {}
  friend bool operator<(const Edge &a, const Edge &b) { return a.c < b.c; }
};
vector<Edge> to[100010];
void Read(int &digit) {
  digit = 0;
  static char c;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    ;
  for (; c >= '0' && c <= '9'; digit = digit * 10 + c - '0', c = getchar())
    ;
}
void read() {
  Read(n), Read(L), Read(R);
  for (int i = 1, a, b, c; i <= n - 1; i++) {
    Read(a), Read(b), Read(c);
    to[a].push_back(Edge(b, c));
    to[b].push_back(Edge(a, c));
    sorted[i] = c;
  }
  sort(sorted + 1, sorted + n);
  cnt = unique(sorted + 1, sorted + n) - sorted - 1;
}
int FindRoot(int p) {
  static int queue[100010], use[100010], size[100010], father[100010];
  int front = 0, rear = 1;
  use[p] = true, queue[rear] = p, size[p] = 1;
  while (front < rear) {
    int p = queue[++front];
    for (int i = 0; i < to[p].size(); i++)
      if (use[to[p][i].v] == false && flag[to[p][i].v] == false) {
        use[to[p][i].v] = true;
        size[to[p][i].v] = 1;
        father[to[p][i].v] = p;
        queue[++rear] = to[p][i].v;
      }
  }
  for (int i = rear; i > 1; i--) {
    size[father[queue[i]]] += size[queue[i]];
    use[queue[i]] = false;
  }
  use[p] = false;
  for (int i = rear; i > 1; i--) {
    int q = queue[i];
    int maxs = size[p] - size[q];
    for (int j = 0; j < to[q].size(); j++)
      if (father[q] != to[q][j].v && maxs < size[to[q][j].v])
        maxs = size[to[q][j].v];
    if (maxs <= size[p] / 2) return queue[i];
  }
  return p;
}
const int sign[] = {1, -1};
int Mid;
bool mark;
void work(int p) {
  static int max1[100010], max2[100010], pos1[100010], pos2[100010];
  static int queue[100010], l[100010], num[100010], sum[100010], dep[100010];
  static bool use[100010];
  int front = 0, rear = 1, cnt = 0;
  queue[rear] = p, use[p] = true;
  dep[p] = 0, sum[p] = 0, num[p] = 0;
  while (front < rear) {
    int p = queue[++front];
    if (dep[p] == R) continue;
    for (int i = 0; i < to[p].size(); i++)
      if (use[to[p][i].v] == false && flag[to[p][i].v] == false) {
        int q = to[p][i].v;
        use[q] = true;
        queue[++rear] = q;
        num[q] = front == 1 ? ++cnt : num[p];
        sum[q] = sum[p] + sign[to[p][i].c < Mid];
        dep[q] = dep[p] + 1;
      }
  }
  l[0] = 1, use[queue[1]] = false;
  for (int i = 2; i <= rear; i++) {
    if (dep[queue[i]] != dep[queue[i - 1]]) l[dep[queue[i]]] = i;
    use[queue[i]] = false;
  }
  for (int i = 1; i <= rear; i++) {
    max1[i] = sum[queue[i - (i & (-i)) + 1]];
    pos1[i] = queue[i - (i & (-i)) + 1];
    max2[i] = -1 << 30;
    for (int j = i - (i & (-i)) + 2; j <= i; j++) {
      int q = queue[j];
      if (max1[i] < sum[q]) {
        if (num[pos1[i]] != num[q])
          max2[i] = max1[i], pos2[i] = pos1[i], pos1[i] = q;
        max1[i] = sum[q], pos1[i] = q;
      } else if (max2[i] < sum[q] && num[pos1[i]] != num[q])
        max2[i] = sum[q], pos2[i] = q;
    }
  }
  for (int i = 1; i <= rear; i++) {
    int x = L - dep[queue[i]], y = R - dep[queue[i]] + 1;
    if (x > dep[queue[rear]]) continue;
    int a = queue[i], r = l[y] - 1;
    if (y > dep[queue[rear]]) r = rear;
    int lim = max(l[x], i + 1);
    for (int j = r; j >= lim;) {
      if (j - (j & (-j)) + 1 < lim) {
        if (num[a] != num[queue[j]] && sum[a] + sum[queue[j]] >= 0) {
          mark = true, ans1 = a, ans2 = queue[j];
          return;
        }
        j--;
      } else {
        if (num[a] == num[pos1[j]]) {
          if (sum[a] + max2[j] >= 0) {
            mark = true, ans1 = a, ans2 = pos2[j];
            return;
          }
        } else {
          if (sum[a] + max1[j] >= 0) {
            mark = true, ans1 = a, ans2 = pos1[j];
            return;
          }
        }
        j -= (j & (-j));
      }
    }
  }
}
void DFS(int p) {
  int Root = FindRoot(p);
  work(Root), flag[Root] = true;
  if (mark) return;
  for (int i = 0; i < to[Root].size(); i++)
    if (flag[to[Root][i].v] == false) {
      DFS(to[Root][i].v);
      if (mark) return;
    }
}
bool check(int v) {
  memset(flag, false, sizeof(flag));
  Mid = v;
  mark = false;
  DFS(1);
  return mark;
}
void binary(int l, int r) {
  if (check(sorted[r])) {
    printf("%d %d\n", ans1, ans2);
    return;
  }
  while (l < r) {
    int mid = (l + r) >> 1;
    check(sorted[mid]) ? l = mid + 1 : r = mid;
  }
  check(sorted[l - 1]);
  printf("%d %d\n", ans1, ans2);
}
int main() {
  read();
  binary(1, cnt);
  return 0;
}
