#Lutece0590. PE class
PE class
Migrated from Lutece 590 PE class
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
The dwarven kingdom and the giant countries classmates have PE class together.
The students' height from cm to cm,everyone's height is different from other's.
There are students in total, and there are pairs of relationship, such as said the student's height stand at position is less than the one stand at position . Can you find each position of the height of students?
Input
The first line of input is the number of test case.
The first line of each test case contains two integers, () and ().
The next line each contain two integers and , indicating the student's height stand at position must be less than the one stand at position . ()
There is a blank line before each test case.
Output
For each test case output one line the students' heights from position to position .
If there are several solutions exist, you should output the one with the smallest height for label , then with the smallest height for label , then with the smallest height for label and so on...
If no solution exists, output one line,just a number .
Output a blank line after each test case.
Samples
4
4 2
1 2
2 1
4 1
2 1
4 1
3 2
3 1
1 1
-1
2 1 3 4
1 3 2 4
-1
Resources
Sichuan University Programming Contest