Case 1 1 2 3 10 9 Case 2 8 9 10 2 1