5 2 1 2 3 4 5 1 4 2 1 2 5 3 2 1 2 2 1
4 5 The tree given in this input is shown below.  For the $1$\-st query, the vertices in the subtree rooted at Vertex $1$ are Vertices $1, 2, 3, 4$, and $5$, so print the $2$\-nd largest value of the numbers written on these vertices, $4$. For the $2$\-nd query, the vertices in the subtree rooted at Vertex $2$ are Vertices $2, 3$, and $5$, so print the $1$\-st largest value of the numbers written on these vertices, $5$.
6 2 10 10 10 9 8 8 1 4 2 1 2 5 3 2 6 4 1 4 2 2
9 10
4 4 1 10 100 1000 1 2 2 3 3 4 1 4 2 3 3 2 4 1
1 10 100 1000
{
"problem": {
"name": "Subtree K-th Max",
"description": {
"content": "We have a rooted tree with $N$ vertices. The vertices are numbered $1$ through $N$, and the root is Vertex $1$. The $i$\\-th edge connects Vertices $A_i$ and $B_i$. Vertex $i$ has an integer $X_i$ ",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc239_e"
},
"statements": [
{
"statement_type": "Markdown",
"content": "We have a rooted tree with $N$ vertices. The vertices are numbered $1$ through $N$, and the root is Vertex $1$. \nThe $i$\\-th edge connects Vertices $A_i$ and $B_i$. \nVertex $i$ has an integer $X_i$ ...",
"is_translate": false,
"language": "English"
}
]
}