median

Time limit: 1.5s Memory limit: 64MB Input: Output:

Task

You are given a tree with NN nodes, numbered from 11 to NN. The edges are numbered from 11 to N1N-1, and edge ii has a weight wiw_i.

Consider a simple path connecting two different nodes. If the weights on this path are wi0wi1wikw_{i_0} \leq w_{i_1} \leq \dots \leq w_{i_k} (not necessarily in this order), then we define its median as wik/2w_{i_{\lfloor k / 2 \rfloor}}.

Let MM be the list of medians of all such simple paths (that is, M=N(N1)2|M| = \frac{N (N-1)}{2}). What is the KKth smallest element of MM?

Input

The first line contains two integers, NN and KK (1N50 0001 \le N \le 50 \ 000), (1KN(N1)/21 \le K \le N * (N-1) / 2). The ii-th of the following N1N-1 lines contains three integers uiu_i, viv_i and wiw_i (1ui,viN1 \le u_i, v_i \le N), (1wi1091 \le w_i \le 10^9), corresponding to an edge of weight wiw_i between nodes uiu_i and viv_i.

For tests worth 88 points, N100N \le 100.

For tests worth 1919 more points, N1 000N \le 1 \ 000.

For tests worth 2424 points, The tree is a bamboo (no node has a degree greater than 22).

Output

The first and only line must contain a single number: the unique integer that solves this task.

Example 1

stdin

3 3
1 2 1
1 3 2

stdout

2

Example 2

stdin

7 15
1 2 3
1 3 1
1 4 4
3 5 1
3 6 5
5 7 9

stdout

3

Explanation

In the first sample case, the elements of MM in increasing order are 1, 1 and 2.

In the second sample case, the elements of MM in increasing order are 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 4, 4, 5, 5 and 9.

Log in or sign up to be able to send submissions!