DS-S95-CA3-1

Time Limit: 2 Seconds    Memory Limit: 65536 KB

You can find the related question in the course page.

Sample Input

3
4 4
1 2
1 3
4 2 
4 3 
3 3 
1 2 
2 3 
3 1
3 0 

Sample Output

1 2 
0 1 
3 1 
Submit