#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const long long inf = 1e18;
bool mark[N];
int sz[N], n, L, R;
int cur, GV;
vector<pair<int, int>> g[N];
long long seg[N << 1];
int st_n;
void init(int x) {
  st_n = x + 5;
  fill(seg, seg + (st_n << 1), -inf);
}
void modify(int p, long long x) {
  p += st_n;
  seg[p] = max(seg[p], x);
  while (p > 1) {
    p >>= 1;
    seg[p] = max(seg[p << 1], seg[p << 1 | 1]);
  }
}
long long get(int l, int r) {
  l += st_n, r += st_n + 1;
  long long res = -inf;
  while (l < r) {
    if (l & 1) {
      res = max(res, seg[l++]);
    }
    if (r & 1) {
      res = max(res, seg[--r]);
    }
    l >>= 1, r >>= 1;
  }
  return res;
}
bool get(int x, int y, long long z) {
  return get(max(0, x), min(cur - 1, y)) >= z;
}
int found;
void check_subtree(int v, int p, long long w, int h) {
  if (h > R) {
    return;
  }
  if (get(L - h, R - h, -w)) {
    found = v;
    return;
  }
  for (auto e : g[v]) {
    if (e.first != p && !mark[e.first]) {
      check_subtree(e.first, v, w + (e.second >= GV ? 1 : -1), h + 1);
      if (found != -1) {
        return;
      }
    }
  }
}
void add_subtree(int v, int p, long long w, int h) {
  modify(h, w);
  for (auto e : g[v]) {
    if (e.first != p && !mark[e.first]) {
      add_subtree(e.first, v, w + (e.second >= GV ? 1 : -1), h + 1);
    }
  }
}
void dfs(int v, int p) {
  sz[v] = 1;
  ++cur;
  for (auto e : g[v]) {
    if (e.first != p && !mark[e.first]) {
      dfs(e.first, v);
      sz[v] += sz[e.first];
    }
  }
}
int get_centroid(int v, int p) {
  for (auto e : g[v]) {
    if (e.first != p && !mark[e.first]) {
      if (sz[e.first] >= cur / 2) {
        return get_centroid(e.first, v);
      }
    }
  }
  return v;
}
void go(int v) {
  cur = 0;
  dfs(v, -1);
  v = get_centroid(v, -1);
  init(cur);
  modify(0, 0);
  for (auto e : g[v]) {
    if (!mark[e.first]) {
      check_subtree(e.first, v, (e.second >= GV ? 1 : -1), 1);
      if (found != -1) {
        return;
      }
      add_subtree(e.first, v, (e.second >= GV ? 1 : -1), 1);
    }
  }
  mark[v] = true;
  for (auto e : g[v]) {
    if (!mark[e.first]) {
      go(e.first);
      if (found != -1) {
        return;
      }
    }
  }
}
bool check(int h) {
  memset(mark, false, sizeof mark);
  GV = h;
  found = -1;
  go(0);
  return found != -1;
}
int find(int v, int p = -1, long long w = 0, int h = 0) {
  if (L <= h && h <= R && w >= 0) {
    return v;
  }
  for (auto e : g[v]) {
    if (e.first != p) {
      int x = find(e.first, v, w + (e.second >= GV ? 1 : -1), h + 1);
      if (x != -1) {
        return x;
      }
    }
  }
  return -1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> L >> R;
  vector<int> nxt;
  init(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    --u, --v;
    g[u].emplace_back(v, w);
    g[v].emplace_back(u, w);
    nxt.push_back(w);
  }
  sort(nxt.begin(), nxt.end());
  nxt.resize(unique(nxt.begin(), nxt.end()) - nxt.begin());
  int l = 0, r = nxt.size();
  while (r - l > 1) {
    int mid = l + r >> 1;
    (check(nxt[mid]) ? l : r) = mid;
  }
  check(nxt[l]);
  cout << found + 1 << ' ' << find(found) + 1 << '\n';
  ;
  return 0;
}
