Codeforces Round 205 (Div. 2)
A
Domino
Codeforces
1200
原题
←B →
翻译中…

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.

翻译中…

Input

翻译中…

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.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

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$.

翻译中…

样例

Input #1
2
4 2
6 4
Output #1
0
InputCopy OutputCopy
Input #2
1
2 3
Output #2
-1
InputCopy OutputCopy
Input #3
3
1 4
2 3
4 4
Output #3
1
InputCopy OutputCopy
题目信息
题号
353A
时间限制
1 s
内存限制
256 MB
标签
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。