I am in a hurry. I have 2D vectors. And I have created all possible subsets of these vectors. For each of these subsets, I have determined the sum of the vectors in that set. Now, I have vectors in front of me. I am not really interested in all of them. I just want to lexicographically sort all these vectors and then pick the th smallest one. As I am in a rush, you will have to do this task for me.
Please note that we consider the sum of vectors for an empty set to be the vector . To lexicographically compare and we first compare and , if then is lexicographically smaller, if then is lexicographically smaller, if then we compare and the smaller number among and belongs to the lexicographically smaller vector.
The first line of the input will contain a positive integer , the number of testcases.
The first line of each testcase will contain two positive integers and . Next lines will contain the vectors. The th line will contain two integers , , the coordinates of the th vector.
For each test case output in a line two integers and , coordinates of the lexicographically th sum.
Input | Output |
---|---|
2 3 4 1 2 5 -1 2 0 3 5 1 -1 -2 3 -2 5 | 3 2 -1 2 |
In the first test case suppose , , . then the created vectors are
empty set