One test case not passed

one of the test case is not passed please help to correct it
link - https://ide.codingblocks.com/s/151863

@kushal1998 Consider test case:
10
-1 0 1 2 3 4 6 6 7 9
3
3
6
10

Expected Output:
4 4
6 7
-1 -1

Your Output:
-1 -1
4 4
4 4
-1 -1
-1 -1
-1 -1
-1 -1

Please dry run your code and check where you are going wrong.