import
java.util.*;
public
class
Main
{
static
class
Node {
public
int
data;
public
Vector<Node> childs;
public
Node(
int
data)
{
this
.data = data;
childs =
new
Vector<Node>();
}
}
static
int
MinimumElement = Integer.MAX_VALUE;
static
void
smallestEleUnderRange(Node root,
int
data)
{
if
(root.data > data) {
MinimumElement = Math.min(root.data, MinimumElement);
}
for
(Node child : root.childs) {
smallestEleUnderRange(child, data);
}
}
static
int
kthSmallestElement(Node root,
int
k)
{
int
ans = Integer.MIN_VALUE;
for
(
int
i =
0
; i < k; i++) {
smallestEleUnderRange(root, ans);
ans = MinimumElement;
MinimumElement = Integer.MAX_VALUE;
}
return
ans;
}
static
Node newNode(
int
data)
{
Node temp =
new
Node(data);
return
temp;
}
public
static
void
main(String[] args) {
Node root = newNode(
10
);
(root.childs).add(newNode(
2
));
(root.childs).add(newNode(
34
));
(root.childs).add(newNode(
56
));
(root.childs).add(newNode(
100
));
(root.childs.get(
0
).childs).add(newNode(
77
));
(root.childs.get(
0
).childs).add(newNode(
88
));
(root.childs.get(
2
).childs).add(newNode(
1
));
(root.childs.get(
3
).childs).add(newNode(
7
));
(root.childs.get(
3
).childs).add(newNode(
8
));
(root.childs.get(
3
).childs).add(newNode(
9
));
System.out.print(kthSmallestElement(root,
3
));
}
}