Domino

题意翻译

## 【问题描述】 Hades与Dionysus在狂饮后玩起了多米诺骨牌的小游戏。 现在桌上有n块多米诺骨牌,每块多米诺骨牌上半部分和下半部分上都有一个整数。每次翻转可让一块多米诺骨牌上下翻转,即上下部分数交换。Hades想让n块骨牌上半部分的数加起来是一个偶数,而Dionysus想让这n块骨牌下半部分的数加起来是一个偶数。喝醉的两人都不肯退让,非要达到自己的目的。路过的Hephaestus在扫了一眼桌上的骨牌后瞬间给出了一个让两人都满意且翻转次数最少的方案,便转身离去,留下迟滞的二人。可这还没完,喝得烂醉的二人很快忘记了Hephaestus所说的方案,Hades说他还记得最少的翻转次数,Dionysus不愿被比下去,只好来请教你了。 ## 【输入格式】 第一行包含一个整数n,表示多米诺骨牌的数量。之后n行每行包含两个分隔的整数xi,yi,初始时xi在上方,yi在下方。 ## 【输出格式】 一个整数,表示所需的最少翻转次数。若无法达到目的,输出-1。

题目描述

Valera has got $ n $ domino pieces in a row. Each piece consists of two halves — the upper one and the lower one. Each of the halves contains a number from $ 1 $ to $ 6 $ . Valera loves even integers very much, so he wants the sum of the numbers on the upper halves and the sum of the numbers on the lower halves to be even. To do that, Valera can rotate the dominoes by $ 180 $ degrees. After the rotation the upper and the lower halves swap places. This action takes one second. Help Valera find out the minimum time he must spend rotating dominoes to make his wish come true.

输入输出格式

输入格式


The first line contains integer $ n $ $ (1<=n<=100) $ , denoting the number of dominoes Valera has. Next $ n $ lines contain two space-separated integers $ x_{i},y_{i} $ $ (1<=x_{i},y_{i}<=6) $ . Number $ x_{i} $ is initially written on the upper half of the $ i $ -th domino, $ y_{i} $ is initially written on the lower half.

输出格式


Print a single number — the minimum required number of seconds. If Valera can't do the task in any time, print $ -1 $ .

输入输出样例

输入样例 #1

2
4 2
6 4

输出样例 #1

0

输入样例 #2

1
2 3

输出样例 #2

-1

输入样例 #3

3
1 4
2 3
4 4

输出样例 #3

1

说明

In the first test case the sum of the numbers on the upper halves equals $ 10 $ and the sum of the numbers on the lower halves equals $ 6 $ . Both numbers are even, so Valera doesn't required to do anything. In the second sample Valera has only one piece of domino. It is written $ 3 $ on the one of its halves, therefore one of the sums will always be odd. In the third case Valera can rotate the first piece, and after that the sum on the upper halves will be equal to $ 10 $ , and the sum on the lower halves will be equal to $ 8 $ .