Say I have 2 columns : Years and Months

There are various entries in each month of the year. As well, the list is not listed

eg:

Year, Month
2005, 1
2005, 1
2007, 12
2006, 3
2006, 5
2005, 6
2007, 3


If the list is sorted, I can use the array formula to find the latest month of the latest year in the list

{=MAX(VLOOKUP(MAX(A:A),A:B,2))}
However, the formula doesn't work if the list is not sorted. What is a good formula to achieve what I need?

Thanks