F. Baker's Dilemma
time limit per test
4.5 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
2
4
3 4
1 1000
2 2
5 5
5
3 4
1 1000
8 8
2 2
5 6
Output
2 1 3 4

2 1 5 3 4