#include<stdio.h>
#include<math.h>
int main()
{
int i,n;
int x,y;
int m1,m2,m3,m4;
while(scanf("%d",&n)!=EOF)
{
m1=;
m2=;
m3=;
m4=;
for(i=; i<n; i++)
{
scanf("%d%d",&x,&y);
if(x&)
{
if(y&)
m1++;//ji ji
else m2++;
}
else
{
if(y&)
m3++;
else m4++;//ou ou
} }
if((m2+m3)%==&&(m2+m3)/>=(m1%))
{
m1=m1%;
m2=m2%;
m3=m3%;
if(m1==&&m2==&&m3==)printf("0\n");
else if(m1==&&m2==&&m3==)printf("0\n");
else printf("1\n");
//printf("%d\n",fabs(m3-m2)/2);
}
else printf("-1\n");
//if() } return ;
}