A forest is collection of trees. Given n trees in a forest, to be constructed in the same way as in question 4, q queries is to be answered. For each query you have to find the kth smallest number in the given tree.
Input Format:
First line contains an integer n1 i.e. number of trees in the forest. For next line onwards there is information about each tree. For each tree first line contains an integer n2 denoting number of nodes in a tree followed by n2 space separated integers. After 2 * n1 such line, there is an integer q denoting total number of queries that need to be answered. Each query consists of two space separated integers n3 and k, where n3 represnets tree number in the forest and k represents kth smallest integer that is to be found.
Output Format:
For each query print a single integer i.e. kth smalles integer in nth tree. If the kth smalles element does not exist then print -1.
Constraints:
All the numbers are well with in integer range.
Note: Using an additional array to sort the tree elements is not allowed.