| 195 | } |
| 196 | |
| 197 | public static void main(String[] args) throws Exception { |
| 198 | FastReader in = new FastReader(System.in); |
| 199 | PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); |
| 200 | n = in.nextInt(); |
| 201 | limitl = in.nextInt(); |
| 202 | limitr = in.nextInt(); |
| 203 | for (int i = 1; i < n; i++) { |
| 204 | arr[i][0] = in.nextInt(); |
| 205 | arr[i][1] = in.nextInt(); |
| 206 | arr[i][2] = in.nextInt(); |
| 207 | } |
| 208 | Arrays.sort(arr, 1, n, (a, b) -> a[2] - b[2]); |
| 209 | cntw = 0; |
| 210 | for (int i = 1; i < n; i++) { |
| 211 | if (i == 1 || arr[i - 1][2] != arr[i][2]) { |
| 212 | cntw++; |
| 213 | } |
| 214 | addEdge(arr[i][0], arr[i][1], cntw); |
| 215 | addEdge(arr[i][1], arr[i][0], cntw); |
| 216 | } |
| 217 | solve(getCentroid(1, 0)); |
| 218 | out.println(ansu + " " + ansv); |
| 219 | out.flush(); |
| 220 | out.close(); |
| 221 | } |
| 222 | |
| 223 | // 读写工具类 |
| 224 | static class FastReader { |