{"raw_statement":[{"iden":"problem statement","content":"You are given a tree with $N$ vertices. The vertices are numbered $1, \\dots, N$, and the $i$\\-th ($1 \\leq i \\leq N - 1$) edge connects Vertices $A_i$ and $B_i$.\nWe define the **distance** between Vertices $u$ and $v$ on this tree by the number of edges in the shortest path from Vertex $u$ to Vertex $v$.\nYou are given $Q$ queries. In the $i$\\-th ($1 \\leq i \\leq Q$) query, given integers $U_i$ and $K_i$, print the index of any vertex whose distance from Vertex $U_i$ is exactly $K_i$. If there is no such vertex, print `-1`."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 2 \\times 10^5$\n*   $1 \\leq A_i \\lt B_i \\leq N \\, (1 \\leq i \\leq N - 1)$\n*   The given graph is a tree.\n*   $1 \\leq Q \\leq 2 \\times 10^5$\n*   $1 \\leq U_i, K_i \\leq N \\, (1 \\leq i \\leq Q)$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $B_1$\n$\\vdots$\n$A_{N-1}$ $B_{N-1}$\n$Q$\n$U_1$ $K_1$\n$\\vdots$\n$U_Q$ $K_Q$"},{"iden":"sample input 1","content":"5\n1 2\n2 3\n3 4\n3 5\n3\n2 2\n5 3\n3 3"},{"iden":"sample output 1","content":"4\n1\n-1\n\n*   Two vertices, Vertices $4$ and $5$, have a distance exactly $2$ from Vertex $2$.\n*   Only Vertex $1$ has a distance exactly $3$ from Vertex $5$.\n*   No vertex has a distance exactly $3$ from Vertex $3$."},{"iden":"sample input 2","content":"10\n1 2\n2 3\n3 5\n2 8\n3 4\n4 6\n4 9\n5 7\n9 10\n5\n1 1\n2 2\n3 3\n4 4\n5 5"},{"iden":"sample output 2","content":"2\n4\n10\n-1\n-1"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}