EasyRating 900
Even Domino Halves
Each domino has an upper and a lower number. You may rotate dominoes (swapping halves), each rotation takes one second. Make the sum of the upper halves and the sum of the lower halves both even. Print the fewest seconds, or -1.
Input
n, then n lines 'x y'.
Output
One integer.
Sample 1
Input
2 4 2 6 4
Output
0
Sample 2
Input
1 2 3
Output
-1
Output appears here