A telephone company wants to build a new telephone network in a city.The company has the goal that each person in the city should be able to call each other person.Of course,it is not possible to build direct connections between every pair of persons.Instead,the company uses a network made up of several layers.
We denote a network switch in layer by .A switch consists of one input,one output and a cable connecting the input to the output.A switch with consists of inputs, outputs and two switches .
Input of () is connected via a cable to the inputs of each of the two switches .Similarly,output of is connected to the outputs of each of the two switches .
We are considering a network with one switch in the outermost layer.It can be shown that any input and output of switch has a unique connection path to any of the switches.Therefore,any input of can be connected to any of its outputs,and the connection path is uniquely determined by specifying through which switch the connection is established.
We number the switches belonging to the switch from to .The -th switch is defined as follows.Write the number in binary as .This defines a path from an input of to the -th switch via the following procedure:for each , indicates that the path extends from to the first switch to which it is directly connected,and indicates that the path extends to the second switch. Note that regardless of which input of is selected,this path arrives at the same switch,which is given the number .See also the figure below the sample data for details of how the numbering works.
Sometimes multiple connections are needed at the same time.In order to avoid interference,each of the inputs and outputs of all switches () can be used by at most one connection.Given a set of connection requests,can you find connection paths for each request such that the connection paths are disjoint?
On the first line a positive integer:the number of test cases,at most .After that per test case:
One line with two integers and :the layer of the outermost switch and the number of connection requests.
lines,each with two integers and .Each such line represents a connection request from input number of to output number .You may assume that the integers are pairwise distinct,and the integers are pairwise distinct as well.
第一行一个正整数,表示测试数据,最多组.
然后每一组包括:
第一个两个数:网络的层数和连接需求数。
接下来行,每行包括两个正整数和。表示输入和输出的编号。和只会出现一次。
输出格式
Per test case:
One line with integers ,where is the number of the switch through which the connection of input to output is established.
The connection paths should be disjoint.You may print any valid solution,and you may assume that there is at least one valid solution.