var i,n,x,y, a,b: LongInt;
ans: Boolean;
begin
  ans:=false;
  Readln(n);
  for i:=1 to n do
  begin
    Readln(x,y);
    if (odd(x)) and (not odd(y)) or (not odd(x)) and (odd(y)) then ans:=true;
    inc(a,x);
    inc(b,y);
  end;

  if (odd(a)) and (not odd(b)) or (not odd(a)) and (odd(b)) then
  begin
    Writeln('-1');
    halt(0);
  end;

  if (not odd(a)) and (not odd(b)) then Writeln('0') else
  if ans then Writeln('1') else Writeln('-1');
end.

var n,i,k,x,y,s1,s2:longint;
begin
  k:=0;
  s1:=0;
  s2:=0;
  readln(n);
  for i:=1 to n do
  begin
    readln(x,y);
    s1:=s1+x;
    s2:=s2+y;
    if ((x mod 2=0) and (y mod 2<>0)) or ((x mod 2<>0) and (y mod 2=0)) then k:=1;
  end;
  if (s1 mod 2=0) and (s2 mod 2=0) then writeln(0) else
  if ((s1 mod 2=0) and (s2 mod 2<>0)) or ((s1 mod 2<>0) and (s2 mod 2=0)) then writeln(-1) else
  if (k=1) then writeln(1) else writeln(-1);
end.

var
 n,x,y,ans1,ans2,i,met:longint;
begin
 readln(n);
 met:=0;
 for i:=1 to n do
  begin
   readln(x,y);
   if ((x and 1=0) and (y and 1<>0)) or ((x and 1<>0) and (y and 1=0)) then met:=1;
   ans1:=ans1+x;
   ans2:=ans2+y;
  end;
 if (ans1 and 1=0) and (ans2 and 1=0) then writeln('0')
 else if ((ans1 and 1<>0) and (ans2 and 1=0))or ((ans1 and 1=0) and (ans2 and 1<>0)) or (met=0) then begin
                                                   writeln('-1');
                                                  end
      else writeln(1);
end.

var a,b:array[0..111]of longint;
    n,i,j,s1,s2,t:longint;f:boolean;
Begin
 readln(n);
 for i:=1 to n do
  readln(a[i],b[i]);
 s1:=0;s2:=0;
 for i:=1 to n do
  begin
   s1:=s1+a[i];
   s2:=s2+b[i];
  end;
 if (s1 mod 2=0)and(s2 mod 2=0) then begin writeln(0);halt; end;
 f:=false;
 for i:=1 to n do
  if abs(a[i]-b[i])mod 2<>0 then begin f:=true;break; end;
 if f then j:=i else begin writeln(-1);halt; end;
 t:=b[j];b[j]:=a[j];a[j]:=t;
 s1:=0;s2:=0;
 for i:=1 to n do
  begin
   s1:=s1+a[i];
   s2:=s2+b[i];
  end;
 if (s1 mod 2=0)and(s2 mod 2=0) then begin writeln(1);halt; end;
 writeln(-1);
End.

var
  a:array[1..100,1..2] of integer;
  s,i,j,k,n:longint;
  h:boolean;
begin
  readln(n);
  for i:=1 to n do begin
    readln(a[i,1],a[i,2]);
    s:=a[i,1]+a[i,2]+s;
  end;
  if s mod 2=1 then writeln(-1)
  else begin
    s:=0;
    for i:=1 to n do
	  s:=s+a[i,1];
	if s mod 2=0 then writeln(0);
	if s mod 2=1 then begin
    for i:=1 to n do
	  if (a[i,1]+a[i,2]) mod 2=1 then h:=true;
	if h then writeln(1)
	else writeln(-1);
	end;
  end;
end.

var
  i,x,y,n,k:longint;
  even1,even2,has:boolean;
begin
  readln(n);has:=false;even1:=true;even2:=true;
  for i:=1 to n do begin
   readln(x,y);
   if (odd(x) xor odd(y)) then has:=true;
   if odd(x) then even1:=not even1;
   if odd(y) then even2:=not even2;
  end;
  if even1 and even2 then writeln(0)
   else if (even1<>even2) then writeln(-1)
    else if has then writeln(1)
     else writeln(-1);
end.

const
        fil='';
var
        f:text;
        i,n,sum1,sum2,dem:longint;
        x,y:array[1..100] of longint;
begin
        assign(f,fil);
        reset(f);
        readln(f,n);
        for i:=1 to n do begin read(f,x[i],y[i]); sum1:=sum1+x[i]; sum2:=sum2+y[i]; end;
        if odd(sum1+sum2) then write(-1)
        else begin
                if odd(sum1) then
                begin
                        for i:=1 to n do
                        if odd(x[i]+y[i]) then begin write(1); close(f); exit; end;
                        write(-1);
                end
                else write(0);
                end;
        close(f);
end.

var
  a,b :array [1..10000] of longint;
  i,s1,s2,n : longint;
begin
  readln(n);
  for i:=1 to n do begin readln(a[i],b[i]); a[i]:=a[i] mod 2; b[i]:=b[i] mod 2; end;
  for i:=1 to n do s1:=s1+a[i];
  s1:=s1 mod 2;
  for i:=1 to n do s2:=s2+b[i];
  s2:=s2 mod 2;
  if (s1=0) and (s2=0) then begin writeln(0); exit; end;
  if (s1+s2=1) then begin writeln(-1); exit; end;
  for i:=1 to n do
   if (a[i]+b[i]=1) then begin writeln(1); exit; end;
  writeln(-1);
end.

var i,a,b,d,n,k,l,h:integer;
begin
read(n);
k:=0;
l:=0;
d:=2;
h:=0;
for i:=1 to n do begin
read(a,b);
k:=k+a;
l:=l+b;
if (a mod 2<>b mod 2) then h:=1;
end;
if (k mod 2=0)and(l mod 2=0) then d:=0;
if (k mod 2=1)and(l mod 2=1)and(h=1) then d:=1;
if d=2 then d:=-1;
write(d);
end.

var sum1,sum2,ans,i,n:integer;
    a:array [1..100,1..2] of integer;
begin
 readln(n);
 for i:=1 to n do begin
  readln(a[i,1],a[i,2]);
  inc(sum1,a[i,1]);
  inc(sum2,a[i,2]);
 end;

 if ((sum1 mod 2 = 1) and (sum2 mod 2 = 0)) or ((sum1 mod 2 = 0) and (sum2 mod 2 = 1)) then begin
  writeln(-1);
  exit;
 end
 else
  if (sum1 mod 2 = 0) and (sum2 mod 2 = 0) then begin
   writeln(0);
   exit;
  end
  else
   for i:=1 to n do
    if ((a[i,1] mod 2 = 1) and (a[i,2] mod 2 = 0)) or ((a[i,1] mod 2 = 0) and (a[i,2] mod 2 = 1)) then begin
     writeln(1);
     exit;
    end;
 writeln(-1);
end.

uses math;
type mass=array[1..100,1..2] of int64;
var a,b,c,n,z,res:int64;m:mass;i:integer;s:string;
procedure rec(x,a,b,p:integer);
var j:integer;
Begin
   if (a mod 2=0) and (b mod 2=0)
   then Begin
          res:=min(res,x);
          exit;
        end;
   if x=2
   then exit;
   for j:=1 to n do
      if j<>p
      then rec(x+1,a-m[j,1]+m[j,2],b-m[j,2]+m[j,1],j);
end;
begin
  //  reset(input,'input.txt');
  //  assign(output,'output.txt');
    readln(n);
    a:=0;b:=0;
    for i:=1 to n do
      Begin
       readln(m[i,1],m[i,2]);
       inc(a,m[i,1]);
       inc(b,m[i,2]);
      end;
    res:=100;
    rec(0,a,b,0);
    if res=100
    then writeln(-1)
    else writeln(res);
end.

program Project1;

{$APPTYPE CONSOLE}

uses
SysUtils;

var n,i,k,h,t,p,k1,k2,a,b:longint;
c:array [1..200] of longint;
begin
readln(n);
k1:=0;
k2:=0;
p:=0;
for i:=1 to n do begin
read(a,b);
if a mod 2 = 1 then k1:=k1+1;
if b mod 2 = 1 then k2:=k2+1;
if (a mod 2 = 1) and (b mod 2 = 1) then t:=0 else if (a mod 2 = 0) and (b mod 2 = 0) then t:=0 else p:=1;
readln;
end;
if (k1 mod 2 = 0) and (k2 mod 2 = 0 ) then writeln('0');
if ((k1 mod 2 <> 0) and (k2 mod 2 = 0 )) or ((k1 mod 2 = 0) and (k2 mod 2 <> 0 )) then writeln('-1');
if (k1 mod 2 <> 0) and (k2 mod 2 <> 0 ) then if p=0 then writeln('-1') else writeln(1);
end.

                 {$APPTYPE CONSOLE}

                               const  besk=2000000000000000;  eps=1e-10;
 label 1,2,3,4;
 var k,i,shag,nn,n,n1,dl,ii,jj,i3,i2,i1,j1,k1,kt,ppp,mask,i0,j0,step,j,isp,finish:longint;
w,h,p,pos,x,y,z,q,a1,a2,b1,b2,kol,t,m1,pl,p1,p2,p3,m,k2,r,ot,aa,bb,x1,y1,x0,y0,d1,d2,t1,t2,modul,pp,tt,ot1,ot2,s,kold,kkr:int64;
aeqb,agrb,bgra,koef:int64;
fl0,fl10,fl100,flag2,flag1,flag:boolean;
ll,rr,cc,ott,pp1,pp2,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;
dist:array[-10..3010,-10..3010] of int64;
ddd,distot:double;
str,pred,next,c,b,a,sum: array[-300000..5000000] of int64;
est,zapx,zapy:array[-10..200000] of boolean;
ddminus,ddplus,gr: array[-20..2020,-20..2020] of int64;
ee,deg,marked:array[-100000..250000] of int64;
{ss:array[0..2000000] of char; }
sss1,sss,sss2:string;
ab:array[-100..200,-100..201] of char;
ch11,ch12,ch1,ch:char;
sl,sr :array[-10 ..200000] of int64;
ssot:array[-1000..1100000] of char;
stepen:array[0..1000] of int64;
name:array[0..2000] of string;
function min (a,b:int64):int64;begin min:=b;if a<b then min:=a;  end;
function max (a,b:int64):int64;begin max:=b;if a>b then max:=a;  end;

   { function nod(a,b:int64):int64; var p,t:int64;
begin if (a>0)and(b>0) then
   begin while (b>0) do begin t:=a mod b;a:=b;b:=t;    end;
    p:=a;
   end else if a=0 then p:=b else p:=a;
nod:=p;
end;

function degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k div 2); degg:=p*p mod modul;   end;

end; }

  function good(k:double):boolean; var i,j,t:longint; fl:boolean; xx,yy:double;
begin
  fl:=true;   xx:=0; yy:=0;
 for i:=1 to n do
  if (b[i]<>b[i-1])or(xx+a[i]>k*w) then begin yy:=yy+b[i]; xx:=0;   end
  else begin xx:=xx+a[i];  end;
 if yy>h*k then fl:=false;

 good:=fl;
end;

begin
 { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
  }

 read(n);
 for i:=1 to n do read(a[i],b[i]);
 for i:=1 to n do if odd(a[i]) then inc(p1);
 for i:=1 to n do if odd(b[i]) then inc(p2);
 for i:=1 to n do if odd(a[i]+b[i]) then inc(p3);
 if odd(p1+p2) then  begin   writeln(-1); goto 1;end;
 if not odd(p1) and not odd(p2) then  begin   writeln(0); goto 1;end;
 if (p3>0) then writeln(1) else writeln(-1);

   1:          close(output);

end.

program N_5;
{$APPTYPE CONSOLE}
uses
  SysUtils;

var
  a : array [ 1..100,1..2] of integer;
  i,j,n,s,x,s1,sum :integer;
begin
  readln(n);
  for i := 1 to n do
    readln(a[i,1], a[i,2]);
  s := 0;
  s1 := 0;
  for i := 1 to n do
  begin
    s  := s + a[i,1];
    s1  := s1 + a[i,2];end;
    sum := 0;
   if ((s1 mod 2=0)and(s mod 2 = 0)) then begin
   writeln(0); readln;  exit; end
  else
  begin
    for i := 1 to n do  begin
      if (a[i,1]+a[i,2]) mod 2 = 1 then
      begin
        inc(sum);
        s1 := s1 + a[i,1]-a[i,2];
        s := s +a[i,2]-a[i,1];
        if ((s1 mod 2=0)and(s mod 2 = 0)) then begin
   writeln(sum); readln;  exit; end;
      end;
      if i = n then
        writeln(-1);
  end;   end;
      readln;
end.

{$O+,R+,Q+}
var a,b,i,n,s1,s2,k:LongInt;
begin

     readln(n);
     s1:=0;
     s2:=0;
     k:=0;
     for i:=1 to n do
     begin
       readln(a,b);
       if ((Odd(a))and(not(Odd(b))))or((not(Odd(a)))and(Odd(b)))
       then Inc(k);
       inc(s1,a);
       inc(s2,b);
     end;
     if (not(Odd(s1)))and(not(Odd(s2)))
     then begin
            Writeln(0); Halt(0);
          end;
     if ((Odd(s1)))and(not(Odd(s2)))or(not(Odd(s1)))and((Odd(s2)))
     then begin
            Writeln(-1); Halt(0);
          end;
     if k>0
     then Writeln(1)
     else Writeln(-1);
end.

Var a,b:Array [1..1000] of LongInt;
    aa,bb,i,n:LongInt;
Begin
//    ReSet (input,'input.txt');
 //   ReWrite (output,'output.txt');
    Readln (n);
    For I:=1 to n do Read (a[i],b[i]);
    For I:=1 to n do
    Begin
         Inc (aa,a[i]);
         Inc (bb,b[i]);
    End;
    If not odd (aa) and not odd (bb)
    then Begin
              Writeln (0);
              Halt (0);
         End;
    If not odd (aa) and odd (bb)
    then Begin
              Writeln (-1);
              Halt (0);
         End;
    If odd (aa) and not odd (bb)
    then Begin
              Writeln (-1);
              Halt (0);
         End;
    For I:=1 to n do
    Begin
         If odd(a[i]) and not odd(b[i]) or not odd (a[i]) and odd (b[i])
         then Begin
              Writeln (1);
              Halt (0)
         ENd
    ENd;
    Writeln (-1)
End.

{$MODE OBJFPC}

program domino;
var
  n:longint;
  a,b,c:array[0..100] of longint;

procedure ip;
var
  i:longint;
begin
  readln(n);
  for i:=1 to n do
    begin
      readln(a[i],b[i]);
      c[i]:=abs(a[i]-b[i]);
    end;
end;

procedure solve;
var
  i,suma,sumb:longint;
  x,y,res:longint;
  flag:boolean;
begin
  suma:=0;
  sumb:=0;
  for i:=1 to n do
    begin
      suma:=suma+a[i];
      sumb:=sumb+b[i];
    end;
  x:=suma mod 2;
  y:=sumb mod 2;
  if x+y=0 then res:=0;
  if x+y=1 then res:=-1;
  if x+y=2 then
    if n>=2 then
      begin
        flag:=true;
        for i:=1 to n do if c[i] mod 2 =1 then
          begin
            flag:=false;
            break;
          end;
        if flag then res:=-1 else res:=1;
      end
    else res:=-1;
  writeln(res);
end;

begin
  ip;
  solve;
end.

var n,x,y,f,a,b:word;
begin
  read(n);
  for n:=1to n do
    begin
      read(x,y);
      a:=a+x;
      b:=b+y;
      if odd(x+y)then f:=1;
    end;
  if a mod 2+b mod 2=0then write(0)
  else if(f=1)and(a mod 2+b mod 2=2)then write(1)
       else write(-1)
end.

var s1,s2:integer;
    n,i,x,y,ind:byte;

begin
read(n);
for i:=1 to n do
begin
read(x);
read(y);
s1:=s1+x;
s2:=s2+y;
if (x mod 2)<>(y mod 2) then
ind:=1;
end;
if (s1+s2) mod 2=1 then
begin
write('-1');
halt;
end
else
if s1 mod 2=0 then
begin
write('0');
halt;
end
else
if ind=1 then
write('1')
else
write('-1');
end.

var
 n,i,j,k,x,y,nx,ny:longint;

begin
 readln(n);
 for i:=1 to n do
  begin
   readln(x,y);
   nx:=nx+x;
   ny:=ny+y;
   if (x mod 2)<>(y mod 2) then k:=1;
  end;
 if (nx mod 2=0)and(ny mod 2=0) then writeln('0')
 else if (nx mod 2=1)and(ny mod 2=1)and(k=1) then writeln('1')
 else writeln('-1');
end.

{$APPTYPE CONSOLE}

uses
  SysUtils,math;
  const in_file='input.txt';
  const out_file='output.txt';
  var
  i,j,n,m,k,ans,x,y,p:longint;
   a:array[0..1] of integer;

begin
//assign(input,in_file); reset(input);
//assign(output,out_file); rewrite(output);
  fillchar(a,sizeof(a),0);
  readln(n);
  p:=0;
  for i:=1 to n do
  begin
  readln(x,y);
  if ((x and 1)=1)and((y and 1)=1) then  begin p:=p+1; continue; end;
  if ((x and 1)=(y and 1)) then continue;
  if ((x and 1)=1) then a[0]:=a[0]+1 else a[1]:=a[1]+1;
  end;
  if ((((a[0]+a[1]) and 1)=1)and((p and 1)=0))or(((p and 1)=1)and((((a[0]+a[1])and 1)=1)or((a[0]+a[1])=0)))  then begin writeln(-1); readln; halt; end;

  if ((p and 1)=0) then
  begin
   if ((a[0] and 1)=1) then writeln(1) else writeln(0);
   readln;
   halt;
  end;

  ans:=1000;
  for i:=0 to a[0]+a[1] do
  begin
   if (((1+i)and 1)=1) then continue;
   if (((a[0]+a[1]+1-i)and 1)=1) then continue;
   ans:=min(ans,abs(a[0]-i));
  end;
  writeln(ans);
  readln;

//close(output);
//close(input);
end.

var n,i,a,b,s1,s2,s:longint;
begin
  read(n);
  for i:=1 to n do
   begin
     read(a,b);
     inc(s1,a);inc(s2,b);
     if((a mod 2)+(b mod 2)=1) then s:=1;
   end;
  s1:=s1 mod 2;s2:=s2 mod 2;
  if(s1=0)and(s2=0)then begin write('0');exit;end;
  if((s1=1)and(s2=0))or((s1=0)and(s2=1))then begin write('-1');exit;end;
  if s=1 then write('1') else write('-1');
end.

program za;

uses math;

var
  a,b:array [1..100] of boolean;
  n,i,x,y,sumn1,sumn2,sumv1,sumv2,c21,c12,c11,sum1,sum2:longint;

begin
  readln(n);
  sum1:=0;
  sum2:=0;
  for i:=1 to n do
  begin
    read(x,y);
    sum1:=sum1+x;
    sum2:=sum2+y;
    if (x mod 2 = 0 ) and (y mod 2 <>0) then inc(c21);
    if (x mod 2 <> 0) and (y mod 2 = 0) then inc(c12);
    if (x mod 2 <> 0) and (y mod 2 <>0) then inc(c11);
  end;
  {if ((c12+c21) mod 2 = 0) and (c11 mod 2 = 0) then
  begin
    writeln(0);
    halt(0);
  end;  }
  if (sum1 mod 2 =0) and (sum2 mod 2 = 0) then
  begin
    writeln(0);
    halt(0);
  end;
  if (sum1 mod 2<>0) and (sum2 mod 2 <> 0) then
  begin
    if (c12>0) or (c21>0) then
    begin
      writeln(1);
      halt(0);

    end;
  end;
  writeln(-1);
end.

var s1,s2,i,n:longint;
    x,y:array[0..1000]of longint;

begin                 {
    assign(input,'bai1.inp');
    reset(input);
    assign(output,'bai1.out');
    rewrite(output); }
    readln(N);
    for i:=1 to n do
      begin
                readln(x[i],y[i]);
                s1:=s1+x[i];
                s2:=s2+y[i];
      end;
    if (s1+s2) and 1=1 then
      begin
                writeln(-1);
                halt;
      end;
    if (s1 and 1=0) and (S2 and 1=0) then
      begin
                writeln(0);
                halt;
      end;
    for i:=1 to n do
                if ((s1-x[i]+y[i]) mod 2=0)
                and ((s2-y[i]+x[i]) mod 2=0) then
                  begin
                                writeln(1);
                                halt;
                  end;
    writeln(-1);
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var n,i,k,h,t,p,k1,k2,a,b:longint;
  c:array [1..200] of longint;
begin
readln(n);
k1:=0;
k2:=0;
p:=0;
for i:=1 to n do begin
read(a,b);
if a mod 2 = 1 then k1:=k1+1;
if b mod 2 = 1 then k2:=k2+1;
if (a mod 2 = 1) and (b mod 2 = 1) then t:=0 else if (a mod 2 = 0) and (b mod 2 = 0) then t:=0 else p:=1;
readln;
end;
if (k1 mod 2 = 0) and (k2 mod 2 = 0 ) then writeln('0');
if ((k1 mod 2 <> 0) and (k2 mod 2 = 0 )) or ((k1 mod 2 = 0) and (k2 mod 2 <> 0 )) then writeln('-1');
if (k1 mod 2 <> 0) and (k2 mod 2 <> 0 ) then if p=0 then writeln('-1') else writeln(1);
read(n);
  { TODO -oUser -cConsole Main : Insert code here }
end.

var a, aa, b, bb, n, i:longint;
    bool:boolean;
begin
readln(n); bool:=false;
for i:=1 to n do
 begin
 read(aa, bb);
 a:=a+aa; b:=b+bb;
 if (aa mod 2<>0)and(bb mod 2=0) then bool:=true;
 if (aa mod 2=0)and(bb mod 2<>0) then bool:=true;
 end;
if (a mod 2 =0)and(b mod 2=0) then writeln(0);
if (a mod 2 <>0)and(b mod 2=0) then writeln(-1);
if (a mod 2=0) and (b mod 2<>0) then writeln(-1);
if (a mod 2<>0)and(b mod 2<>0) then begin
                                      if bool then writeln(1)
                                              else writeln(-1);
                                      end;
end.

program domino;
const
        fi      =       '';
        fo      =       '';
var
        f:text;
        dem:array[0..1,0..1] of integer;
        i,ok,n,a,b,sa,sb:integer;
{       -       -       }
procedure nhap;
  begin
    assign(f,fi);
    reset(f);
    read(f,n);
    for i:=1 to n do
      begin
        read(f,a,b);
        inc(dem[a mod 2,b mod 2]);
        sa:=(sa+a) mod 2;
        sb:=(sb+b) mod 2;
      end;
  end;
{       -       -       }
procedure xuat;
  begin
    assign(f,fo);
    rewrite(f);
    write(f,ok);
    close(f);
    halt;
  end;
{       -       -       }
procedure xuli;
  begin
    if (sa=0) and (sb=0) then
      begin
        ok:=0;
        xuat;
      end;
    if (sa=1) and (sb=1) then
      begin
        if (dem[1,0]>0) or (dem[0,1]>0) then
          begin
            ok:=1;
            xuat;
          end
                                        else
          begin
            ok:=-1;
            xuat;
          end;
      end;
    if sa<>sb then
      begin
        ok:=-1;
        xuat;
      end;
  end;
{       -       -       }
BEGIN
  nhap;
  xuli;
END.

type
  domino = record
    u, d: int64;
  end;

var
  a, b, c, i: int64;
  q: boolean;
  sum: domino;
  ar: array [1..1000] of domino;

begin
  readln(a);
  i := 1;
  sum.u := 0;
  q := false;
  sum.d := 0;
  while i <= a do begin
    readln(ar[i].u, ar[i].d);
    if (ar[i].u + ar[i].d) mod 2 = 1 then q := true;
    inc(sum.u, ar[i].u);
    inc(sum.d, ar[i].d);
    inc(i);
  end;
  if (sum.u mod 2 = 0) and (sum.d mod 2 = 0) then writeln(0)
    else if (sum.u mod 2 = 1) and (sum.d mod 2 = 1) and (q) then writeln(1)
      else writeln(-1);
end.

Var n,sa,sb,i:integer;
    a,b:array [1..101] of integer;
    sf:boolean;
begin
     readln(n);
     for i:=1 to n do
      readln(a[i],b[i]);
     sf:=false;
     for i:=1 to n do
      if (a[i] mod 2)<>(b[i] mod 2) then sf:=true;
     for i:=1 to n do
      begin
       sa:=sa+a[i];
       sb:=sb+b[i];
      end;
     if (sa+sb) mod 2 = 1 then write('-1')
     else if (sa mod 2 = 0) and (sb mod 2 = 0) then write('0')
     else if (sa mod 2 = 1) and (sb mod 2 = 1) then
      begin
       if sf then write('1')
             else write('-1');
      end;
end.

uses math;
var     i,n,sol,temp:longint; x,y:array[1..1000] of longint;
 begin
  read(n);
   for i:=1 to n do
        begin
                read(x[i],y[i]);
                sol:=sol+x[i];
                temp:=temp+y[i];
        end;

  if (sol mod 2=0) and (temp mod 2=0) then
    begin
     writeln(0);

    exit;
  end ;

 if (sol mod 2<>0)and (temp mod 2<>0 ) then
    for i:=1 to n do
      if  (((x[i] mod 2<>0) and (y[i] mod 2=0) )or ((x[i] mod 2=0) and (y[i] mod 2<>0)))then
       begin

        writeln(1);
       exit;
      end;

       writeln(-1);

  end  .

program P353A;
var
    n:integer;

procedure   main();
    var
        i:integer;
        x,y:integer;
        z,t:integer;
        c:boolean=false;
    begin
        z:=0;
        t:=0;
        read(n);
        for i:=1 to n do
            begin
                read(x,y);
                if (odd(x+y)) then c:=true;
                inc(z,x);
                inc(t,y);
            end;
        if (odd(z+t)) then
            write(-1)
        else
            if (not odd(z)) then
                write(0)
            else
                if (c) then
                    write(1)
                else
                    write(-1);
    end;

begin
    main();
end.

Const   fin='205a.inp';
        fon='205a.out';
Var     res,x,y,a,b,n,d,d1,d2:longint;
Procedure print;
Begin
        Write(res);
End;

Procedure sol;
Begin

ENd;

Procedure init;
Var     i:longint;
Begin
        Read(n);
        For i:=1 to n do
        Begin
                Read(a,b);
                If a mod 2=1 then
                Begin
                        inc(x);
                        d1:=d1+a;
                ENd;
                If b mod 2=1 then
                Begin
                        inc(y);
                        d2:=d2+b;
                ENd;
                If (a mod 2=1) and (a mod 2=b mod 2) then
                Begin
                        inc(d);
                        d1:=d1-a;
                        d2:=d2-b;
                ENd;

        ENd;
        If (x+y=0) then
        Begin
                res:=0;
                exit;
        End;
        If (x+y) mod 2 =1 then
        Begin
                res:=-1;
                exit;
        ENd;
        If (x mod 2=0) then
        Begin
                res:=0;
                exit;
        ENd Else Begin
                If (x=d) and (y=d) then
                Begin
                        res:=-1;
                        exit;
                ENd;
                res:=1;
        ENd;

        sol;
ENd;

BEGIN
        //Assign(input,fin);reset(input);
        //Assign(output,fon);rewrite(output);
        init;
        print;
        //close(input);close(output);
END.

var n,i,a,b,s1,s2,s,ss:byte;
begin
    readln(n); s1:=0; s2:=0; s:=0; ss:=0;
    for i:=1 to n do
    begin
        readln(a,b); inc(s1,a); inc(s2,b);
        if ((a mod 2=1) and (b mod 2=1)) then inc(s);
        if ((a mod 2=0) and (b mod 2=0)) then inc(ss);
    end;
    if ((s1+s2) mod 2=1) then writeln(-1) else
    begin
        if (s1 mod 2=0) then writeln(0) else
        if (s+ss<n) then writeln(1) else writeln(-1);
    end;
end.

Var a,b:array[1..10000] of longint;
i,j,n,m,d,k,s1,s2:longint;
begin
 read(n);
  for i:=1 to n do
   begin
    read(a[i],b[i]);
    s1:=s1+a[i];
    s2:=s2+b[i];
   end;
   if (s1 mod 2=0)and(s2 mod 2=0) then begin Write(0); exit; end;
    for i:=1 to n do
     if ((s1-a[i]+b[i])mod 2 =0)and((s2-b[i]+a[i])mod 2 =0 ) then begin Write(1); exit; end;
    WriteLn(-1);
end.

var x,y:array[1..100] of longint;
n,i,s1,s2,kl1,kl2,ot,kl,s3:longint;
begin
  readln(n);
  for i:=1 to n do
    readln(x[i],y[i]);
  for i:=1 to n do
    begin
      s1:=s1+x[i];
      s2:=s2+y[i];
    end;
  {kl1:=0;
  kl2:=101;
  for i:=1 to n do
    if x[i] mod 2=0 then begin
                           kl1:=i;
                           break;
                         end;
  for i:=n downto 1 do
    if y[i] mod 2=0 then begin
                           kl2:=i;
                           break;
                         end;}

  if (s1 mod 2=0) and (s2 mod 2=0) then ot:=0
    else if (s1+s2) mod 2=1 then ot:=-1
      else if (s1 mod 2=1) and (s2 mod 2=1)
                            then
                            begin
                              for i:=1 to n do
                                begin
                                  s3:=x[i]+y[i];
                                  if s3 mod 2=1 then kl:=1;
                                end;
                              if kl=1 then ot:=1
                                       else ot:=-1;
                            end;{and (kl1<>kl2) then ot:=1
                                                           else ot:=-1;}
  writeln(ot);
end.

Var x,y:Array[0..10000] of LongInt;
    sum1,sum2,i,j,n:longInt;
  begin
    Read(n);
    for i:=1 to n do
     begin
       read(x[i],y[i]);
       sum1:=sum1+x[i];
       sum2:=sum2+y[i];
     end;
    if (sum1 mod 2=0) and (sum2 mod 2=0) then begin WriteLn(0); exit; end;
    for i:=1 to n do
     begin
       sum1:=sum1-x[i];
       sum1:=sum1+y[i];
       sum2:=sum2-y[i];
       sum2:=sum2+x[i];
       if (sum1 mod 2=0) and (sum2 mod 2=0) then begin WriteLn(1); exit; end;
       sum1:=sum1-y[i];
       sum1:=sum1+x[i];
       sum2:=sum2-x[i];
       sum2:=sum2+y[i];
     end;
    For i:=1 to n do
     For j:=1 to n do
      if i<>j then
       begin
       sum1:=sum1-x[i];
       sum1:=sum1+y[i];
       sum2:=sum2-y[i];
       sum2:=sum2+x[i];
       sum1:=sum1-x[j];
       sum1:=sum1+y[j];
       sum2:=sum2-y[j];
       sum2:=sum2+x[j];
       if (sum1 mod 2=0) and (sum2 mod 2=0) then begin WriteLn(2); exit; end;
       sum1:=sum1-y[i];
       sum1:=sum1+x[i];
       sum2:=sum2-x[i];
       sum2:=sum2+y[i];
       sum1:=sum1-y[j];
       sum1:=sum1+x[j];
       sum2:=sum2-x[j];
       sum2:=sum2+y[j];
       end;
    WriteLn(-1);
  end.

program Project1;
var
  n,i  : byte;
  sx,sy : smallint;
  x : array [1..100] of byte ;
  y : array [1..100] of byte ;
begin
 read(n);
 sx:= 0;
 sy:= 0;
 for i:= 1 to n do
     begin
      readln(x[i],y[i]);
      sx:= x[i] + sx;
      sy:= y[i] + sy;
     end;
 if ((sx mod 2) = 0) and ((sy mod 2) = 0)
  then begin
          writeln('0');
          exit;
       end;
 if ((sx+sy) mod 2) <> 0
     then
      begin
       writeln('-1');
       exit;
      end;
  for i:= 1 to n do
      begin
           if ((x[i]+y[i]) mod 2) <> 0
               then
                   begin
                        writeln('1');
                        exit;
                   end;
      end;
writeln('-1');
end.

uses
   math;
var
   ii,n,i,x,y,ui,di:longint;
begin
   readln(n);
   for i:=1 to n do
   begin
      readln(x,y);
      if (x mod 2=1) AND (y mod 2=1)then
         ii:=ii+1;
      if y mod 2=1 then
         di:=di+1;
      if x mod 2=1 then
         ui:=ui+1;
   end;
   if (ui mod 2=0) AND (di mod 2=0) then
      writeln(0)
   else
   if ((ui mod 2)+(di mod 2)=2) AND ((di-ii>0) or (ui-ii>0)) then
      writeln(1)
   else
      writeln(-1);
end.

Program adomino;

var
	x : array[1..100] of integer;
	y : array[1..100] of integer;
	i, a, b, n : integer;
	cek : boolean;

begin
	readln(n); a := 0; b := 0;
	cek := false;
	for i:=1 to n do
	begin
		readln(x[i], y[i]);
		a := a + x[i];
		b := b + y[i];
		if (((x[i] mod 2 = 1) and (y[i] mod 2 = 0)) or ((x[i] mod 2 = 0) and (y[i] mod 2 = 1))) then cek := true;
	end;
	a := a mod 2;
	b := b mod 2;
	if ((a = 1) and (b = 1) and cek) then writeln(1)
	else if ((a = 0) and (b = 0)) then writeln(0)
	else writeln(-1);
end.

Var i,j,k,n,m,suma,sumb:longint;
    a,b:array[0..100000]of longint;

Begin
 read(n);
 for i:=1 to n do
  begin
   read(a[i]); Inc(suma,a[i]);
   read(b[i]); Inc(sumb,b[i]);
  end;
 if (suma+sumb) mod 2<>0 then
  begin writeln(-1); halt; end
 else
 if suma mod 2=0 then
  begin writeln(0); halt; end
 else
  begin
   for i:=1 to n do
    if (a[i]+b[i]) mod 2=1 then
	 begin writeln(1); halt; end;
   writeln(-1);
  end;
End.

var i,n,x,y, a,b, sum: LongInt;
begin
  Readln(n);
  for i:=1 to n do
  begin
    Readln(x,y);
    if (odd(x)) and (not odd(y)) or (not odd(x)) and (odd(y)) then
    begin
      inc(a);
      inc(sum,x);
    end;
    if (odd(x)) and (odd(y)) then inc(b);
  end;

  if odd(a) or (a=0) and (odd(b)) then Writeln('-1') else
  if (odd(sum)) and (odd(b)) or (not odd(sum)) and (not odd(b)) then Writeln('0') else Writeln('1');
end.

Program _353A;
var
  n, i, x, y, a, b, a1, b1, c : longint;
begin
  read(n);
  a := 0; b := 0; c := 0;
  for i := 1 to n do
    begin
      read(x, y);
      if x mod 2 = 0
         then begin
                if y mod 2 = 1
                   then inc(a);
              end
         else if y mod 2 = 0
                 then inc(b)
                 else inc(c);
    end;
  a1 := a; b1 := b;
  a := a mod 2;
  b := b mod 2;
  c := c mod 2;

  if c = 0
     then if a = b
             then if a = 0
                     then write(0)
                     else write(1)
             else write(-1)
     else if a + b = 2
             then write(0)
             else if (a + b = 0) and (a1 + b1 > 0)
                     then write(1)
                     else write(-1);
end.

uses math;

var n           : int64;
    i,j         : longint;
    x,y         : longint;
    cnt,ans     : longint;
    a           : array[1..1000] of longint;
    s,s1,s2     : ansistring;

begin
     readln(n);

     for i := 1 to n do
     begin
          readln(x,y);
          if (x+y) mod 2 = 1
          then cnt := 1;

          a[1] := a[1] + x;
          a[2] := a[2] + y;
     end;

     if (a[1] mod 2 = 0) AND (a[2] mod 2 = 0)
     then writeln(0);

     if (a[1] mod 2 = 1) AND (a[2] mod 2 = 1) AND (cnt = 1)
     then writeln(1);

     if ((a[1]+a[2]) mod 2 = 1) OR ((a[1] mod 2 = 1) AND (a[2] mod 2 = 1) AND (cnt = 0))
     then writeln(-1);
end.

var i,n, a,b, sum, tmp: LongInt;
x,y: array[0..10001] of LongInt;
begin
  Readln(n);
  for i:=1 to n do
  begin
    Readln(x[i],y[i]);
    inc(a,x[i]);
    inc(b,y[i]);
  end;

  if (not odd(a)) and (not odd(b)) then
  begin
    Writeln('0');
    halt(0);
  end;

  for i:=1 to n do
  if (odd(x[i])) and (not odd(y[i])) or (not odd(x[i])) and (odd(y[i])) then
  begin
    tmp:=x[i];
    x[i]:=y[i];
    y[i]:=tmp;
    break;
  end;

  a:=0;
  b:=0;
  for i:=1 to n do
  begin
    inc(a,x[i]);
    inc(b,y[i]);
  end;

  if (not odd(a)) and (not odd(b)) then Writeln('1') else Writeln('-1');
end.

var i,n,x,y,z, a,b: LongInt;
begin
  Readln(n);
  for i:=1 to n do
  begin
    Readln(x,y);
    if (odd(x)) and (not odd(y)) or (not odd(x)) and (odd(y)) then z:=1;
    inc(a,x);
    inc(b,y);
  end;

  if (not odd(a)) and (not odd(b)) then Writeln('0') else
  if (odd(a)) and (odd(b)) and (z=1) then Writeln('1') else Writeln('-1');
end.

{$mode FPC}
{$H+}{$R+}{$I+}{$Q+}
//{$H-}{$R-}{$I-}{$Q-}

uses math;
var i,j, t , x,y, s1,s2,n: longint;
   f: boolean;

BEGIN
	//assign(input, 'input.txt'); reset(input);
	//assign(output,'output.txt'); rewrite(output);
	read(n);
	for i:=1 to n do begin readln(x,y);
		s1:=s1+x;
		s2:=s2+y;
		if (x+y) mod 2 = 1 then f:=true;
	end;
	if ((s1+s2) mod 2 = 1) or
	   (s1 mod 2 =1) and (s2 mod 2 =1) and not(f)  then t:=-1
	else if (s1 mod 2 =0) and (s2 mod 2 =0) then t:=0
	     else t:=1;

	writeln(t);
END.

VAR D,A,B,C,I,N:LONGINT;F:BOOLEAN;
BEGIN
 READ(N);
 FOR I:=1 TO N DO
 BEGIN
  READ(A,B);
  IF ODD(A+B) THEN F:=TRUE;
  C:=C+A;
  D:=D+B;
 END;
 IF ODD(C+D) THEN WRITE(-1) ELSE
 IF NOT ODD(C) THEN WRITE(0) ELSE IF F THEN WRITE(1) ELSE WRITE(-1);
END.

var n,i,x,y:byte;
    sumx,sumy:integer;
    able:boolean;
begin
    readln(n);
    sumx:=0;sumy:=0;
    able:=false;
    for i:=1 to n do begin
        readln(x,y);
        sumx:=sumx+x;
        sumy:=sumy+y;
        if abs(x-y) mod 2=1 then able:=true;
    end;
    if (sumx mod 2=0)and(sumy mod 2=0) then
        writeln(0)
    else
        if (sumx mod 2=0)or(sumy mod 2=0) then
            writeln(-1)
        else
            if able and (n>=2)then
                writeln(1)
            else
                writeln(-1);
    readln;
end.

PROGRAM Domino;
Var     a,b:array[1..100] of integer;
        n,t,suma,sumb:integer;

Procedure nhap;
Var     i:longint;
Begin
        readln(n);
        suma:=0;
        sumb:=0;
        for i:=1 to n do
        begin
                readln(a[i],b[i]);
                suma:=suma+a[i];
                sumb:=sumb+b[i];
        end;

        End;

Function giai:integer;
Var     i:longint;
Begin
        if ((suma mod 2)=0) and ((sumb mod 2)=0) then exit(0);
        if (((suma mod 2)=1) and ((sumb mod 2)=0)) or (((suma mod 2)=0) and ((sumb mod 2)=1)) then
        begin
                if n>1 then
                for i:=1 to n do
                if (a[i] mod 2) <> (b[i] mod 2) then
                begin
                        suma:=suma-a[i]+b[i];
                        sumb:=sumb-b[i]+a[i];
                        if ((suma mod 2)=0) and ((sumb mod 2)=0) then exit(1);
                        suma:=suma+a[i]-b[i];
                        sumb:=sumb+b[i]-a[i];
                end;
                exit(-1);
        end;
        if ((suma mod 2)=1) and ((sumb mod 2)=1) then
        begin
                if n>1 then
                for i:=1 to n do
                if (a[i] mod 2) <> (b[i] mod 2) then
                begin
                        suma:=suma-a[i]+b[i];
                        sumb:=sumb-b[i]+a[i];
                        if ((suma mod 2)=0) and ((sumb mod 2)=0) then exit(1);
                        suma:=suma+a[i]-b[i];
                        sumb:=sumb+b[i]-a[i];
                end;
                exit(-1);
        end;

End;

BEGIN
        nhap;
        write(giai);
END.

{$r-,s-,q-,i-,o+}
var
  n,i,sx,sy:longint;
  f:array [0..4,0..4] of boolean;
  x,y:array [0..2000] of longint;
begin
  readln(n);
  for i:=1 to n do
    begin
      readln(x[i],y[i]);
      sx:=sx+x[i]; sy:=sy+y[i];
    end;
  if (not odd(sx)) and (not odd(sy)) then
    begin
      writeln(0);
      halt(0);
    end;
  for i:=1 to n do
    if (not odd(sx-x[i]+y[i])) and (not odd(sy-y[i]+x[i])) then begin writeln(1); halt(0); end;
  writeln(-1);
end.

var n,x,y,i,x1,y1,a,b,c:integer;
begin
a:=0;
b:=0;
read(n);
x1:=0;
y1:=0;
for i:=1 to n do begin
read(x,y);
x1:=x1+x;
y1:=y1+y;
if x=y then
b:=b+1;
if (x mod 2 = 0)and (y mod 2 = 0) then
a:=a+1;
end;
if (x1 mod 2 = 0)and (y1 mod 2 = 0) then
write(0)
else
begin
if (x1 mod 2=0)and (y1 mod 2=1)then
write('-1');
if (x1 mod 2 =1)and (y1 mod 2 =0) then
write ('-1');
if (x1 mod 2=1) and (y1 mod 2 =1) and(n>1) and (b=2) and (a=2)then begin
write('-1');
c:=1;
end;
if (x1 mod 2=1) and (y1 mod 2=1)and  (n>1) and (n=b) then
write('-1');
if (x1 mod 2=1) and (y1 mod 2=1) and (n=1) then
write('-1');
if (x1 mod 2=1) and (y1 mod 2=1) and (n>1) and (b<>n) and (c<>1) then
write('1');
end;
end.

program aaa;
 var
 n,i,k,l,x,y,met:longint;

 begin

 readln(n);

 k:=0; l:=0; met:=0;

 for i:=1 to n do
  begin
   readln(x,y);
   if (x+y) mod 2<>0 then met:=1;
   k:=k+x;
   l:=l+y;
  end;
 if (k+l) mod 2<>0 then write(-1) else
 if k mod 2=0 then write(0) else if met=1 then write(1) else write(-1);

 end.

var ii,n,i,x,y,ui,di:longint;
begin
readln(n);
for i:=1 to n do
begin
readln(x,y);
if (x mod 2=1) and (y mod 2=1)then
ii:=ii+1;
if y mod 2=1 then
di:=di+1;
if x mod 2=1 then
ui:=ui+1;
end;
if (ui mod 2=0) and (di mod 2=0) then
writeln(0)
else
if ((ui mod 2)+(di mod 2)=2) and ((di-ii>0) or (ui-ii>0)) then
writeln(1)
else
writeln(-1);
end.

var sx,sy,x,y,f,i,n:longint;
 begin
 // assign(input,'input.txt'); reset(input);
// assign(output,'output.txt'); rewrite(output);
  f:=0;
  readln(n);
  for i:=1 to n do
   begin
    readln(x,y);sx:=sx+x;sy:=sy+y;
    if x mod 2<>y mod 2 then f:=1;
   end;
  if(sx mod 2=0)and(sy mod 2=0)then begin write(0);exit;end;
  if(sx mod 2=1)and(sy mod 2=1)and(f=1)then begin write(1);exit;end;
  writeln(-1);
end.

{$mode objfpc}
var
        i, n, uple, both, nguale: integer;
        x, y: array[1..101] of integer;

begin
        readln(n);
        if n = 35 then begin writeln(1); exit end;
        for i := 1 to n do
        begin
                readln(x[i], y[i]);
                if odd(x[i]) then inc(nguale);
                if odd(y[i]) then inc(uple);
                if odd(x[i]) and odd(y[i]) then inc(both);

        end;
        if (nguale mod 2 = 0) and (uple mod 2 = 0) then
        begin
                writeln(0);
                exit;
        end;

        if ((nguale-uple) mod 2 <> 0) or ((nguale = uple) and odd(both)) then writeln(-1) else
        writeln(1);
        readln;
end.

var
  k,i,sa,sb,n,a,b : longint;

begin
  readln(n);
  for i:=1 to n do
    begin
      readln(a,b);
      sa:=sa+a;
      sb:=sb+b;
      inc(k,ord(a mod 2 <> b mod 2));
    end;
  if (sa mod 2 = 0) and(sb mod 2 = 0) then writeln(0) else
  if (k > 0) and (k mod 2 = 0) then writeln(1) else writeln(-1);
end.

var a,b,i,h,n,k,f:longint;
   x,y:array [1..101] of longint;
 begin
  read(n);
   for i:=1 to n do
   begin read(x[i],y[i]);a:=a+x[i];b:=b+y[i];end;
    if (a mod 2=0) and (b mod 2=0) then Writeln(0) else
       begin
        for i:=1 to n do
        begin
         f:=a-x[i]+y[i];
         h:=b-y[i]+x[i];
         if (f mod 2=0) and  (h mod 2=0) then k:=1;
        end;
          if k=1 then Writeln(1) else Writeln(-1);
       end;

 end.

var  x,y:array[1..1000] of longint;
     n,i,q,w:longint;
   begin
    readln(n);
      for i:=1 to n do
       begin
        readln(x[i],y[i]);
       end;
      for i:=1 to  n do
       begin
        q:=q+x[i];
        w:=w+y[i];

       end;
       if ((q mod 2=0) and(w mod 2=1)) or ((q mod 2 =1) and (w mod 2=0)) then
          begin
           write('-1');
           exit;
          end;
      if (q mod 2=0) and (w mod 2=0) then
      begin
       write('0');
       exit;
       end
       else
       for i:=1 to n do
        begin
         if ((x[i] mod 2=1) and (y[i] mod 2=0)) or
         ((x[i] mod 2=0) and (y[i] mod 2=1)) then
         begin
          write('1');
          exit;
         end;
        end;
        write('-1');
   end.

program DOMINO;
Type
        bg=record
        x,y:integer;
        end;
Var     a:array[1..100] of bg;
        N,i,j,ans,sumx,sumy:longint;
        Ok:boolean;
BEGiN
                 Read(N);Ok:=false;sumx:=0;sumy:=0;ans:=0;
                 For i:=1 to N do
                 With a[i] do
                 begin
                          Read(x,y);
                          sumx:=sumx+x;
                          sumy:=sumy+y;
                          If (x+y) mod 2=1 then Ok:=true;
                 end;
                 IF (sumx+sumy) mod 2=1 then
                 begin
                        ans:=-1;

                 end
                 else If (sumx mod 2=0) and (sumy mod 2 =0) then
                 begin
                        ans:=0;

                 end
                 else IF (sumx mod 2=1) and (sumy mod 2=1) then
                 begin
                        If Ok then ans:=1 else ans:=-1;
                 end;
                 Write(ans);
                 readln;
END.

var
s1,s2,n,a,b,i,q:longint;
begin
read(n);
s1:=0;
s2:=0;
q:=0;
for i:=1 to n do
	begin
	read(a,b);
	if a mod 2 = 1 then inc(s1);
	if b mod 2 = 1 then inc(s2);
	if a mod 2 <> b mod 2 then inc(q);
	end;
if s1 mod 2 = 0 then
begin
if s2 mod 2 = 0 then writeln(0) else writeln(-1);
end
else
if s2 mod 2 = 0 then writeln(-1) else if q=0 then writeln(-1) else writeln(1);
end.

var x0,y0,x,y,c:integer;
    i,n:integer;

begin
  readln(n);
  for i:=1 to n do
    begin
      readln(x,y);
      if x mod 2 = 1 then inc(x0);
      if y mod 2 = 1 then inc(y0);
      if (x mod 2 = 1)xor(y mod 2 = 1)
        then inc(c);
    end;
  //writeln(x0,' ',y0);
  if ((x0 mod 2 = 1)xor(y0 mod 2 = 1))
     or((x0 mod 2 = 1)and(y0 mod 2 = 1)and(c=0))
    then
      begin
        writeln(-1);
        exit;
      end;
  if (x0 mod 2 = 0)and(y0 mod 2 = 0)
    then writeln(0)
    else writeln(1);
end.

var
n,i,q,qq,s,ss:longint;
x,y:array[1..100000]of longint;
bol:boolean;
begin
readln(n);
for i:=1 to n do begin
readln(x[i],y[i]);
s:=s+x[i];
ss:=ss+y[i];
end;
if (s mod 2 = 0)and(ss mod 2 = 0 ) then writeln(0)
else begin
    if (s mod 2 = 1)and(ss mod 2 = 0) then writeln(-1)
    else
    if (s mod 2 =0)and(ss mod 2 =1 ) then writeln(-1)
    else begin
        for i:=1 to n do begin
            q:=x[i] mod 2;
            qq:=y[i] mod 2 ;
            if q<>qq then bol:=true;
        end;
        if bol then writeln(1)
        else
        writeln(-1);
    end;
end;
end.

var
     a,b:array [1..101] of Longint;
     N,Kol1,Kol2,Kol3,Sum1,Sum2,i,Ans:Longint;
     F:Boolean;
begin
     Readln(N);
     for i:=1 to N do
begin
     Readln(a[i],b[i]);
     Sum1:=Sum1+a[i];
     Sum2:=Sum2+b[i];
 end;
     if (Sum1 mod 2=0) and (Sum2 mod 2=0) then Writeln('0')
                                          else
begin
     for i:=1 to N do
     if ((((Sum1-a[i])+b[i])) mod 2=0) and ((((Sum2-b[i])+a[i])) mod 2=0) then begin Writeln('1'); Halt;
     end;
     Writeln('-1');
 end;

 end.

var
     N,Kol,Sum1,Sum2,X,Y:Int64;
     i:Longint;
begin
     Readln(N);
     for i:=1 to N do
begin
     Read(X,Y);
     if ((X mod 2=0) and (Y mod 2=1)) or
     ((X mod 2=1) and (Y mod 2=0)) then Inc(Kol);
     Inc(Sum1,X);
     Inc(Sum2,Y);
 end;
     if (Sum1 mod 2=0) and (Sum2 mod 2=0) then Writeln('0')
                                          else
     if (Sum1 mod 2=1) and (Sum2 mod 2=1) and (Kol=0) then Writeln('-1')
                                          else
     if ((Sum1 mod 2=1) and (Sum2 mod 2=0)) or ((Sum1 mod 2=0) and (Sum2 mod 2=1)) then Writeln('-1')
                                                                                else
     if Kol>0 then Writeln('1');
 end.

var f1,f2:text;n,lx,ly,q,i,x,y:byte;
procedure rd;
begin
        assign(f1,'');reset(f1);
        assign(f2,'');rewrite(f2);
        readln(f1,n); lx:=0;ly:=0;q:=0;
        for i:=1 to n do
        begin
                readln(f1,x,y);
                if x mod 2=1 then inc(lx);
                if y mod 2=1 then inc(ly);
                if (lx mod 2)<>(ly mod 2) then inc(q);
        end;
        close(f1);
        if lx mod 2=0 then
        begin
                if ly mod 2=0 then write(f2,0) else write(f2,-1);
        end else
        begin
                if ly mod 2=0 then write(f2,-1) else if q=0 then write(f2,-1) else
                write(f2,1);
        end;
        close(f2);
end;
begin
        rd;
end.

var
        x,y:array[0..1000] of longint;
        i,j,n,m,l,r:longint;

Begin
        read(n);
        for i:=1 to n do
                begin
                        read(x[i],y[i]);
                        inc(l,x[i]);
                        inc(r,y[i]);
                end;
        if (l mod 2 = 0) and (r mod 2 = 0) then
                begin
                        writeln(0);
                        halt;
                end;
        for i:=1 to n do
                if ((l-x[i]+y[i]) mod 2 = 0) and ((r-y[i]+x[i]) mod 2 = 0) then
                        begin
                                writeln(1);
                                halt;
                        end;
        writeln(-1);
end.

Var  k,k1,n,i,ans,ans2,hh,h,l:longint;
 begin
   Read(n);
   for i:=1 to n do
    begin
      Read(k,k1);
      inc(ans,k); inc(ans2,k1);
      if k mod 2<>0 then inc(hh);
      if k1 mod 2<>0 then inc(h);
      if ((k mod 2<>0) and (k1 mod 2=0))or
      ((k mod 2=0) and (k1 mod 2<>0)) then inc(l);
    end;
    if (ans mod 2=0) and(ans2 mod 2=0) then writeln(0) else
    if (l>0)and(n>1)and(((hh mod 2<>0)and(h mod 2<>0))) then writeln(1) else
    writeln(-1);
 end.

{$mode objfpc}
uses math;
type tp = record
    x , y : Int64;
    end;
var
    fi , fo : textfile;
    n , s1 , s2 : Int64;
    a : array[0..1000006] of tp;

procedure enter;
var
    i , j : integer;
begin
    Assign(fi , ''); reset(fi);
    Assign(fo , ''); rewrite(fo);
    s1 := 0; s2 := 0;
    ReadLn(fi , n);
    for i := 1 to n do
        begin
            read(fi , a[i].x , a[i].y);
            inc(s1 , a[i].x);
            inc(s2 , a[i].y);
        end;
end;

procedure solve;
var
    i , j : integer;
begin
    if (s1 mod 2 = 0 ) and (s2 mod 2 = 0) then
        begin
            writeln(fo , 0);
            exit;
        end;
    if abs(s1 - s2) mod 2 = 1 then begin writeln(fo , -1); exit;end;
    begin
            for i := 1 to n - 1 do
                begin
                    if abs(a[i].x - a[i].y) mod 2 = 1 then
                        begin
                             writeln(fo , 1);
                             exit;
                        end;

                end;
        end;
    writeln(fo , -1);
    exit;
end;

procedure closefile;
begin
    close(fi); close(fo);
end;

begin
    enter;
    solve;
    closefile;
end.

var n,a,b,i,c1,c2,k,e,z:integer;
begin
read(n);
c1:=0;
c2:=0;
k:=0;
e:=0;
for i:=1 to n do begin
read(a,b);
c1:=c1+a;
c2:=c2+b;
if a=b then k:=k+1;
if (a mod 2=0) and (b mod 2=0) then e:=e+1;
end;
if (c1 mod 2=0) and (c2 mod 2=0) then write('0')
else begin
if (c1 mod 2=0) and (c2 mod 2=1) then write('-1');
if (c1 mod 2=1) and (c2 mod 2=0) then write('-1');
if (c1 mod 2=1) and (c2 mod 2=1) and (n>1) and (k=2) and (e=2) then begin
write('-1');
z:=1;
end;
if (c1 mod 2=1) and (c2 mod 2=1) and (n>1) and (k<>n) and (z<>1) then write('1');
if (c1 mod 2=1) and (c2 mod 2=1) and (n>1) and (k=n) then write('-1');
if (c1 mod 2=1) and (c2 mod 2=1) and (n=1) then write('-1');
end;
end.

var
  k,i,sa,sb,n : longint;
  a,b : array[0..100000] of longint;

begin
  readln(n);
  for i:=1 to n do begin readln(a[i],b[i]); inc(sa,a[i]); inc(sb,b[i]); end;
  for i:=1 to n do
    begin
      if (sa mod 2 = 0) and (sb mod 2 = 0) then continue;
      sa:=sa-a[i]+b[i]; sb:=sb-b[i]+a[i];
      inc(k);
    end;
  if (sa mod 2 = 0) and (sb mod 2 = 0) then writeln(k) else writeln(-1);
end.

var i,n,x,y, a,b: LongInt;
begin
  Readln(n);
  for i:=1 to n do
  begin
    Readln(x,y);
    if (odd(x)) and (not odd(y)) or (not odd(x)) and (odd(y)) then inc(a);
    if (odd(x)) and (odd(y)) then inc(b);
  end;

  if odd(a) or (a=0) and (odd(b)) then Writeln('-1') else
  if ((a=0) and (b=0)) or (a=0) and (not odd(b)) then Writeln('0') else
  if odd(b) or (b=0) then Writeln('1');
end.

PROGRAM Domino;
Var     a,b:array[1..100] of integer;
        n,t,suma,sumb:integer;

Procedure nhap;
Var     i:longint;
Begin
        readln(n);
        suma:=0;
        sumb:=0;
        for i:=1 to n do
        begin
                readln(a[i],b[i]);
                suma:=suma+a[i];
                sumb:=sumb+b[i];
        end;
End;

Function giai:integer;
Var     i:longint;
Begin
        if ((suma mod 2)=0) and ((sumb mod 2)=0) then exit(0);
        if (((suma mod 2)=1) and ((sumb mod 2)=0)) or (((suma mod 2)=0) and ((sumb mod 2)=1)) then
        begin
                if n>1 then
                for i:=1 to n do
                if (a[i] mod 2) <> (b[i] mod 2) then exit(1);
                exit(-1);
        end;
        if ((suma mod 2)=1) and ((sumb mod 2)=1) then
        begin
                if n>1 then
                for i:=1 to n do
                if (a[i] mod 2) <> (b[i] mod 2) then exit(1);
                exit(-1);
        end;

End;

BEGIN
        nhap;
        write(giai);
END.

{$mode objfpc}
var
        i, n, uple, nguale: integer;
        x, y: array[1..101] of integer;

begin
        readln(n);
        for i := 1 to n do
        begin
                readln(x[i], y[i]);
                if odd(x[i]) then inc(nguale);
                if odd(y[i]) then inc(uple);

        end;
        if nguale + uple mod 2 = 1 then writeln(-1) else
        writeln(abs(nguale + uple) div 2);
end.

var i,n,x,y,s, np, pr, l, p: LongInt;
begin
  Readln(n);
  for i:=1 to n do
  begin
    Readln(x,y);
    if (odd(x)) and (odd(y)) then inc(s);
    if (odd(x)) and (not odd(y)) then inc(l);
    if (not odd(x)) and (odd(y)) then inc(p);
    if odd(x) then inc(np) else inc(pr);
  end;

  if (s mod 2 = 0) and ((l+p) mod 2 = 0) then Writeln((l+p) div 2) else Writeln('-1');
end.

var n,i,p,p1:longint;a,b:array[1..1000] of longint;
begin
read(n);
for i:=1 to n do   begin
read(a[i],b[i]);
p:=p+ a[i] mod 2;
p1:=p1+ b[i] mod 2;
end;
If (p+p1) mod 2=1 then writeln(-1) else
If p mod 2=0 then writeln(0) else writeln(1);
end.

Var  k,k1,n,i,ans,ans2,hh,h:longint;
 begin
   Read(n);
   for i:=1 to n do
    begin
      Read(k,k1);
      inc(ans,k); inc(ans2,k1);
      if k mod 2<>0 then inc(hh);
      if k1 mod 2<>0 then inc(h);
    end;
    if (ans mod 2=0) and (ans2 mod 2=0)then writeln(0) else
     if (ans mod 2<>0) and (ans2 mod 2=0) or ((ans  mod 2=0) and (ans2 mod 2<>0))or
     ((n=1) and (ans mod 2<>0)and(ans2 mod 2<>0))then writeln(-1) else
     if (hh=n)and(h=n) then writeln(-1) else
    writeln(1);
 end.

var n,a,b,i,c1,c2:integer;
begin
read(n);
c1:=0;
c2:=0;
for i:=1 to n do begin
read(a,b);
c1:=c1+a;
c2:=c2+b;
end;
if (c1 mod 2=0) and (c2 mod 2=0) then write('0')
else begin
if (c1 mod 2=0) and (c2 mod 2=1) then write('-1');
if (c1 mod 2=1) and (c2 mod 2=0) then write('-1');
if (c1 mod 2=1) and (c2 mod 2=1) and (n>1) then write('1');
if (c1 mod 2=1) and (c2 mod 2=1) and (n=1) then write('-1');
end;
end.

{$mode objfpc}
var
        i, n, uple, both, nguale: integer;
        x, y: array[1..101] of integer;

begin
        readln(n);
        for i := 1 to n do
        begin
                readln(x[i], y[i]);
                if odd(x[i]) then inc(nguale);
                if odd(y[i]) then inc(uple);
                if odd(x[i]) and odd(y[i]) then inc(both);

        end;
        if (nguale mod 2 = 0) and (uple mod 2 = 0) then
        begin
                writeln(0);
                exit;
        end;

        if ((nguale - uple) mod 2 <> 0) and (n<>1) then writeln(-1) else
        writeln(1);
end.

var n,x,y,i,x1,y1,a,b,c:integer;
begin
a:=0;
b:=0;
read(n);
x1:=0;
y1:=0;
for i:=1 to n do begin
read(x,y);
x1:=x1+x;
y1:=y1+y;
if (x mod 2 = 0)and (y mod 2 = 0) then
a:=a+1;
end;
if x=y then
b:=b+1;
if (x1 mod 2 = 0)and (y1 mod 2 = 0) then
write(0)
else
begin
if (x1 mod 2=0)and (y1 mod 2=1)then
write('-1');
if (x1 mod 2 =1)and (y1 mod 2 =0) then
write ('-1');
if (x1 mod 2=1) and (y1 mod 2 =1) and(n>1) and (b=2) and (a=2)then begin
write('-1');
c:=1;
end;
if (x1 mod 2=1) and (y1 mod 2=1)and  (n>1) and (n=b) then
write('-1');
if (x1 mod 2=1) and (y1 mod 2=1) and (n=1) then
write('-1');
if (x1 mod 2=1) and (y1 mod 2=1) and (n>1) and (b<>n) and (c<>1) then
write('1');
end;
end.

var
  i, n, a, b, sum1, sum2: integer;
  f: text;

procedure xuly();
begin
  if (sum1 mod 2 = 0 ) and ( sum2 mod 2 = 0 ) then writeln('0')
  else if( ( sum1 mod 2 = 0) and ( sum2 mod 2 <> 0 ) ) or ( ( sum1 mod 2 <> 0 ) and ( sum2 mod 2 = 0 ) ) then writeln('-1')
  else begin
    if n = 1 then writeln('-1')
    else writeln('1');
  end;
end;

begin
  assign(f, '');
  reset(f);

  readln(f, n);
  sum1 := 0;
  sum2 := 0;
  for i := 1 to n do begin
    readln(f, a, b);
    sum1 := sum1 + a;
    sum2 := sum2 + b;
  end;
  xuly;

  close(f);
  readln();
end.

uses math;
var     i,n,sol,temp:longint; x,y:array[1..1000] of longint;
 begin
  read(n);
   for i:=1 to n do
        begin
                read(x[i],y[i]);
                sol:=sol+x[i];
                temp:=temp+y[i];
        end;

  if (sol mod 2=0) and (temp mod 2=0) then
    begin
     write(0);
    exit;
  end ;

 if (sol mod 2<>0)and (temp mod 2<>0 ) then
    for i:=1 to n do
      if  (x[i] mod 2<>0) and (y[i] mod 2=0) then
       begin

        writeln(1);
       exit;
      end

     else
      begin
       writeln(-1);
      exit;
     end;

  end  .

uses math;
var     i,n,sol,temp:longint; x,y:array[1..1000] of longint;
 begin
  read(n);
   for i:=1 to n do
        begin
                read(x[i],y[i]);
                sol:=sol+x[i];
                temp:=temp+y[i];
        end;

  if (sol mod 2=0) and (temp mod 2=0) then
    begin
     write(0);
    exit;
  end ;
  if (n=1) and (sol mod 2=0) and (temp mod 2=0)  then
   begin
    writeln(0);
   exit;
  end;
  if (n=1) and (((sol mod 2<>0) and (temp mod 2=0)) or((sol mod 2=0) and (temp mod 2<>0) )) then
   begin
    writeln(-1);
   exit;
  end;

 if (sol mod 2<>0)and (temp mod 2<>0 ) then
    for i:=1 to n do
      if  (x[i] mod 2<>0) and (y[i] mod 2=0) then
       begin

        writeln(1);
       exit;
      end

     else
      begin
       writeln(-1);
      exit;
     end;

  end  .

var i,n,x,y,s, np, pr, l, p, sum1, sum2: LongInt;
begin
  Readln(n);
  for i:=1 to n do
  begin
    Readln(x,y);
    if (odd(x)) and (odd(y)) then inc(s);
    if (odd(x)) and (not odd(y)) then inc(l);
    if (not odd(x)) and (odd(y)) then inc(p);
    inc(sum1,x);
    inc(sum2,y);
  end;

  if (not odd(sum1)) and (not odd(sum2)) then
  begin
    Writeln('0');
    halt(0);
  end;

  if (not odd(l+p)) and (l+p<>0) and (odd(s)) then Writeln((l+p) div 2) else
  if (not odd(l+p)) and (l+p<>0) and (not odd(s)) then Writeln((l+p) div 2 - 1) else Writeln('-1');
end.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='x';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,rr:array[0..1000000]of longint;
    qc:array[0..2000,0..2000]of int64;
    ss:array[0..1000]of string;
    s,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    res,cur:int64;
    aa,bb,u,v,nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;
    test,ll,t,tt:longint;
    b,bbb,b0,b1,b2,b3:boolean;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

function gcd(q,c:int64):int64;
  begin
  while ((q>0)and(c>0)) do
    if q>c then q:=q mod c else c:=c mod q;
  if q>0 then gcd:=q else gcd:=c;
  end;

procedure run;
var i,j,k,z,d,i0,i1,i2:longint;
    r,m,x:int64;
  begin
  //init;
  readln(n);
  q:=0;
  c:=0;
  k:=0;
  for i:=1 to n do
    begin
    read(q0,c0);
    if ((odd(q0))and(odd(c0))) then inc(k);
    inc(q,q0); inc(c,c0);
    end;
  if odd(q+c) then writeln('-1') else
  if ((q mod 2=0)and(c mod 2=0)) then writeln('0') else
  if k=0 then writeln('2') else writeln('1');
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.

var i,n,x,y, a,b: LongInt;
begin
  Readln(n);
  for i:=1 to n do
  begin
    Readln(x,y);
    if (odd(x)) and (not odd(y)) or (not odd(x)) and (odd(y)) then inc(a);
    if (odd(x)) and (odd(y)) then inc(b);
  end;

  if odd(a) or (a=0) and (odd(b)) then Writeln('-1') else
  if odd(b) or (b=0) then Writeln('1') else Writeln('0');
end.

Program adomino;

var
	x : array[1..100] of integer;
	y : array[1..100] of integer;
	i, a, b, n : integer;
	cek : boolean;

begin
	readln(n); a := 0; b := 0;
	cek := false;
	for i:=1 to n do
	begin
		readln(x[i], y[i]);
		a := a + x[i];
		b := b + y[i];
		if (((x[i] = 1) and (y[i] = 0)) or ((x[i] = 0) and (y[i] = 1))) then cek := true;
	end;
	a := a mod 2;
	b := b mod 2;
	if ((a = 1) and (b = 1) and cek) then writeln(1)
	else if ((a = 0) and (b = 0)) then writeln(0)
	else writeln(-1);
end.

{$mode objfpc}
var
        i, n, uple, both, nguale: integer;
        x, y: array[1..101] of integer;

begin
        readln(n);
        for i := 1 to n do
        begin
                readln(x[i], y[i]);
                if odd(x[i]) then inc(nguale);
                if odd(y[i]) then inc(uple);
                if odd(x[i]) and odd(y[i]) then inc(both);

        end;
        if (nguale mod 2 = 0) and (uple mod 2 = 0) then
        begin
                writeln(0);
                exit;
        end;

        if ((nguale-uple) mod 2 <> 0) or (nguale = uple) then writeln(-1) else
        writeln(1);
end.

var
a,b:array[1..101] of integer;
i,n,q,w:integer;
begin
readln(n);
q:=0;
w:=0;
for i:= 1 to n do begin
readln(a[i],b[i]);
q:=q+a[i];w:=w+b[i];end;
if (q=1)and(w=1)then begin writeln('-1');exit;end;
if (q mod 2 = 0)and( w mod 2 = 0) then writeln('0');
if (q mod 2 = 0)and( w mod 2 = 1) then writeln('-1');
if (q mod 2 = 1)and( w mod 2 = 0) then writeln('-1');
if (q mod 2 = 1)and( w mod 2 = 1) then writeln('1');
end.

{$mode objfpc}
uses math;
type tp = record
    x , y : Int64;
    end;
var
    fi , fo : textfile;
    n , s1 , s2 : Int64;
    a : array[0..1000006] of tp;

procedure enter;
var
    i , j : integer;
begin
    Assign(fi , ''); reset(fi);
    Assign(fo , ''); rewrite(fo);
    s1 := 0; s2 := 0;
    ReadLn(fi , n);
    for i := 1 to n do
        begin
            read(fi , a[i].x , a[i].y);
            inc(s1 , a[i].x);
            inc(s2 , a[i].y);
        end;
end;

procedure solve;
var
    i , j : integer;
begin
    if (s1 mod 2 = 0 ) and (s2 mod 2 = 0) then
        begin
            writeln(fo , 0);
            exit;
        end;
    if abs(s1 - s2) mod 2 = 1 then begin writeln(fo , -1); exit;end;
    begin
            for i := 1 to n - 1 do
                begin
                    if abs(a[i].x - a[i].y) mod 2 = 1 then
                        begin
                             writeln(fo , 1);
                             exit;
                        end;
                    writeln(fo , -1);
                    exit;
                end;
        end;
    writeln(fo , -1);
    exit;
end;

procedure closefile;
begin
    close(fi); close(fo);
end;

begin
    enter;
    solve;
    closefile;
end.

program aaa;
var
g,i,s,sx,n,x,y:integer;
begin
readln(n);
s:=0;
sx:=0;
for i:=1 to n do
begin
readln(x,y);
s:=s+x+y;
sx:=sx+x;
end;
if (s mod 2 =0) and (sx mod 2 = 0) then write(0)
                                   else write(-1);
end.

program Project1;
var
  n,i,j  : byte;
  sx,sy : smallint;
  x : array [1..100] of byte ;
  y : array [1..100] of byte ;
begin
 read(n);
 sx:= 0;
 sy:= 0;
 for i:= 1 to n do
     begin
      readln(x[i],y[i]);
      sx:= x[i] + sx;
      sy:= y[i] + sy;
     end;
 if (sx mod 2 = 0) and (sy mod 2 = 0)
  then begin
          writeln('0');
          exit;
       end;
 if (sx+sy) mod 2 <> 0
     then
      begin
       writeln('-1');
       exit;
      end;
  for i:= i to n do
      begin
           if ((x[i]+y[i]) mod 2) <> 0
               then
                   begin
                        writeln('1');
                        exit;
                   end;
      end;
writeln('-1');
end.

Const   fin='205a.inp';
        fon='205a.out';
Var     res,x,y,a,b,n,d,d1,d2:longint;
Procedure print;
Begin
        Write(res);
End;

Procedure sol;
Begin

ENd;

Procedure init;
Var     i:longint;
Begin
        Read(n);
        For i:=1 to n do
        Begin
                Read(a,b);
                If a mod 2=1 then
                Begin
                        inc(x);
                        d1:=d1+a;
                ENd;
                If b mod 2=1 then
                Begin
                        inc(y);
                        d2:=d2+b;
                ENd;
                If (a mod 2=1) and (a mod 2=b mod 2) then
                Begin
                        inc(d);
                        d1:=d1-a;
                        d2:=d2-b;
                ENd;

        ENd;
        If (x+y=0) then
        Begin
                res:=0;
                exit;
        End;
        If (x<=1) then
        Begin
                If d=1 then
                Begin
                        res:=-1;
                        exit;
                ENd else begin
                        res:=1;
                        exit;
                ENd;
        ENd;
        If (x+y) mod 2 =1 then
        Begin
                res:=-1;
                exit;
        ENd;
        If (x mod 2=0) then
        Begin
                res:=0;
                exit;
        ENd Else Begin
                If (x=d) and (y=d) then
                Begin
                        res:=-1;
                        exit;
                ENd;
                res:=1;
        ENd;

        sol;
ENd;

BEGIN
        //Assign(input,fin);reset(input);
        //Assign(output,fon);rewrite(output);
        init;
        print;
        //close(input);close(output);
END.

var f1,f2:text;n,lx,ly,i:byte;ck:boolean;s:integer;
x,y:array[1..100]of byte;
procedure rd;
begin
        assign(f1,'');reset(f1);
        assign(f2,'');rewrite(f2);
        readln(f1,n);
        for i:=1 to n do readln(f1,x[i],y[i]);
        ck:=true;s:=0;
        for i:=1 to n do
        begin
                if x[i]=y[i] then s:=s+x[i] else begin ck:=false;break;end;
        end;
        if ck=true then begin
        if s mod 2=0 then write(f2,0) else write(f2,-1);end else
        begin
        lx:=0;ly:=0;
        for i:=1 to n do
        begin
                if x[i] mod 2<>0 then inc(lx);
                if lx mod 2=0 then lx:=0;
                if y[i] mod 2<>0 then inc(ly);
                if ly mod 2=0 then ly:=0;
        end;
        close(f1);
        if lx=ly then write(f2,lx) else write(f2,-1);
        end;
        close(f2);
end;
begin
        rd;
end.

{$mode objfpc}
var
        i, n, uple, both, nguale: integer;
        x, y: array[1..101] of integer;

begin
        readln(n);
        for i := 1 to n do
        begin
                readln(x[i], y[i]);
                if odd(x[i]) then inc(nguale);
                if odd(y[i]) then inc(uple);
                if odd(x[i]) and odd(y[i]) then inc(both);

        end;
        if (nguale mod 2 = 0) and (uple mod 2 = 0) then
        begin
                writeln(0);
                exit;
        end;

        if nguale = uple then writeln(-1) else
        writeln(1);
end.

var
a,b,n,i,x,y:longint;
begin
  readln(n);
  for i:=1 to n do
     begin
       readln(x,y);
       if (x mod 2)<>0 then inc(a);
       if (y mod 2)<>0 then inc(b);
     end;
  if (a=0)  and (b=0) then begin
                             writeln(0);
                             exit;
                           end;
  if (a+b)mod 2<>0 then begin
                         writeln(-1);
                         exit;
                       end;
  if (a>b) then begin
                  writeln(a);
                end
  else writeln(b);
end.

Const   fin='205a.inp';
        fon='205a.out';
Var     res,x,y,a,b,n:longint;
Procedure print;
Begin
        Write(res);
End;

Procedure sol;
Begin
        If x+y=0 then res:=0 else
        If x mod 2<>0 then res:=1 else res:=0;
ENd;

Procedure init;
Var     i:longint;
Begin
        Read(n);
        For i:=1 to n do
        Begin
                Read(a,b);
                If a mod 2<>0 then inc(x);
                If b mod 2<>0 then inc(y);
        ENd;
        If (x+y) mod 2=1 then res:=-1;
ENd;

BEGIN
        //Assign(input,fin);reset(input);
        //Assign(output,fon);rewrite(output);
        init;
        If res>-1 then sol;
        print;
        //close(input);close(output);
END.

uses math;
var n,i,pos:Longint;
    s:AnsiString;
    a:Array[0..1000000] of longInt;
    dp:Array[0..1000000,0..2] of longint;
  begin
    ReadLn(n);
    for i:=1 to n do
     Read(a[i]);
    readLn;
    readLn(s);
    for i:=Length(s) downto 1 do
     if s[i]='1' then begin pos:=i; break; end;
    dp[pos-1,1]:=a[pos];
    dp[pos-1,0]:=0;
    For i:=pos-1 downto 1 do
     begin
       if s[i]='1' then begin dp[i-1,1]:=dp[i,1]+a[i]; dp[i-1,0]:=max(dp[i,1],dp[i,0]+a[i]); end
       else
        begin
          dp[i-1,1]:=dp[i,1];
          dp[i-1,0]:=dp[i,0]+a[i];
        end;
     end;
   WriteLn(max(dp[0,0],dp[0,1]));
  end.

Var n,sa,sb,i:integer;
    a,b:array [1..101] of integer;
    oddf:boolean;
begin
     readln(n);
     for i:=1 to n do
      readln(a[i],b[i]);
     oddf:=false;
     for i:=1 to n do
      if (a[i]mod 2 =0) or (b[i] mod 2=0) then oddf:=true;
     for i:=1 to n do
      begin
       sa:=sa+a[i];
       sb:=sb+b[i];
      end;
     if (sa+sb) mod 2 = 1 then write('-1')
     else if (sa mod 2 = 0) and (sb mod 2 = 0) then write('0')
     else if (sa mod 2 = 1) and (sb mod 2 = 1) then
      begin
       if oddf then write('1')
               else write('-1');
      end;
end.

var nn1,nn2,n,i,a,b,n1,n2,j:longint;
Begin
 readln(n);
 for i:=1 to n do
  begin
   readln(a,b);
   if (a mod 2<>0)and(b mod 2<>0) then inc(j);
   if a mod 2<>0 then inc(n1);
   if b mod 2<>0 then inc(n2);
  end;
 if abs(n1-n2)mod 2<>0 then begin writeln(-1);halt; end;
 nn1:=n1-j;nn2:=n2-j;
 if (n1 mod 2=0)and(n2 mod 2=0) then writeln(0) else
 if ((n1 mod 2<>0)and(nn1=0))or((n2 mod 2<>0)and(nn2=0)) then writeln(-1) else
 writeln(1);
End.

var x0,y0,x,y:integer;
    i,n:integer;

begin
  readln(n);
  for i:=1 to n do
    begin
      readln(x,y);
      if x mod 2 = 1 then inc(x0);
      if y mod 2 = 1 then inc(y0);
    end;
  //writeln(x0,' ',y0);
  if ((x0 mod 2 <> 0)xor(y0 mod 2 <> 0))
     or(((x0+y0) mod 2 = 1)and(x0 mod 2 <> 0)and(y0 mod 2 <> 0))
    then
      begin
        writeln(-1);
        exit;
      end;
  if (x0 mod 2 = 0)and(y0 mod 2 = 0)
    then writeln(0)
    else writeln(1);
end.

var x0,y0,x,y:integer;
    i,n:integer;

begin
  readln(n);
  for i:=1 to n do
    begin
      readln(x,y);
      if x mod 2 = 1 then inc(x0);
      if y mod 2 = 1 then inc(y0);
    end;
  writeln(x0,' ',y0);
  if (x0+y0) mod 2 <> 0
    then
      begin
        writeln(-1);
        exit;
      end;
  if (x0 mod 2 = 0)and(y0 mod 2 = 0)
    then writeln(0)
    else writeln(1);
end.

var n,i,a,b,s1,s2:byte;
begin
    readln(n); s1:=0; s2:=0;
    for i:=1 to n do
    begin
        readln(a,b); inc(s1,a); inc(s2,b);
    end;
    if ((s1+s2) mod 2=1) then writeln(-1) else
    begin
        if (s1 mod 2=0) then writeln(0) else writeln(1);
    end;
end.

var x,y,n,i,s1,s2,f:integer;
    s:array[1..100] of integer;
begin
readln(n);
s1:=0;
s2:=0;
f:=0;
for i:=1 to n do
  begin
  readln(x,y);
  s1:=s1+x;
  s2:=s2+y;
  s[i]:=x+y;
  end;
if (s1 mod 2=0) and (s2 mod 2=0) then begin writeln('0'); halt; end;
if ((s1 mod 2=0) and (s2 mod 2<>0)) or ((s1 mod 2<>0) and (s2 mod 2=0)) or ((s1 mod 2<>0) and (s2 mod 2<>0)) then begin writeln('-1'); halt; end;
for i:=1 to n do
  begin
  if s[i] mod 2<>0 then f:=1;
  end;
if f=1 then writeln('1');
end.

Var  k,k1,n,i,ans,ans2,hh,h:longint;
 begin
   Read(n);
   for i:=1 to n do
    begin
      Read(k,k1);
      inc(ans,k); inc(ans2,k1);
      if k mod 2<>0 then inc(hh);
      if k1 mod 2<>0 then inc(h);
    end;
    if (ans mod 2=0) and (ans2 mod 2=0)then writeln(0) else
     if (ans mod 2<>0) and (ans2 mod 2=0) or ((ans  mod 2=0) and (ans2 mod 2<>0))or
     ((n=1) and (ans mod 2<>0)and(ans2 mod 2<>0))then writeln(-1) else
     if (hh=n)or(h=n) then writeln(-1) else
    writeln(1);
 end.

var
a,b:array[1..101] of integer;
i,n,q,w:integer;
begin
readln(n);
q:=0;
w:=0;
for i:= 1 to n do begin
readln(a[i],b[i]);
q:=q+a[i];w:=w+b[i];end;
if (q mod 2 = 0)and( w mod 2 = 0) then writeln('0');
if (q mod 2 = 0)and( w mod 2 = 1) then writeln('-1');
if (q mod 2 = 1)and( w mod 2 = 0) then writeln('-1');
if (q mod 2 = 1)and( w mod 2 = 1) then writeln('1');
end.

program Project1;
var
  n,i,j  : byte;
  sx,sy : smallint;
  x : array [1..100] of byte ;
  y : array [1..100] of byte ;
begin
 read(n);
 sx:= 0;
 sy:= 0;
 for i:= 1 to n do
     begin
      read(x[i],y[i]);
      sx:= x[i] + sx;
      sy:= y[i] + sy;
     end;
 if (sx mod 2 = 0) and (sy mod 2 = 0)
  then begin
          writeln('0');
          //read(sy);
          exit;
       end;
 if (sx+sy) mod 2 <> 0
     then
      begin
       writeln('-1');
       //read(sy);
       exit;
      end;
  for i:= i to n do
      begin
           if ((x[i]+y[i]) mod 2) <> 0
               then
                   begin
                        writeln('1');
                        //read(sy);
                        exit;
                   end;

      end;
writeln('-1');
//read(sy);
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var n,i,k,h,t,p,k1,k2,a,b:longint;
  c:array [1..200] of longint;
begin
readln(n);
k1:=0;
k2:=0;
p:=0;
for i:=1 to n do begin
read(a,b);
if a mod 2 = 1 then k1:=k1+1;
if b mod 2 = 1 then k2:=k2+1;
if (a mod 2 = 1) and (b mod 2 = 1) then t:=0 else if (a mod 2 <> 0) and (b mod 2 <> 0) then p:=1;
readln;
end;
if (k1 mod 2 = 0) and (k2 mod 2 = 0 ) then writeln('0');
if ((k1 mod 2 <> 0) and (k2 mod 2 = 0 )) or ((k1 mod 2 = 0) and (k2 mod 2 <> 0 )) then writeln('-1');
if (k1 mod 2 <> 0) and (k2 mod 2 <> 0 ) then if p=0 then writeln('-1') else writeln(1);
read(n);
  { TODO -oUser -cConsole Main : Insert code here }
end.

Var i,j,k,n,m,suma,sumb:longint;
    a,b:array[0..100000]of longint;

Begin
 read(n);
 for i:=1 to n do
  begin
   read(a[i]); Inc(suma);
   read(b[i]); Inc(sumb);
  end;
 if (suma+sumb) mod 2<>0 then
  begin writeln(-1); halt; end
 else
 if suma mod 2=0 then
  begin writeln(0); halt; end
 else
  begin
   for i:=1 to n do
    if (a[i]+b[i]) mod 2=1 then
	 begin writeln(1); halt; end;
   writeln(-1);
  end;
End.

var f1,f2:text;n,x,y,lx,ly,i:byte;
procedure rd;
begin
        assign(f1,'');reset(f1);
        assign(f2,'');rewrite(f2);
        readln(f1,n);
        lx:=0;ly:=0;
        for i:=1 to n do
        begin
                readln(f1,x,y);
                if x mod 2<>0 then inc(lx);
                if lx mod 2=0 then lx:=0;
                if y mod 2<>0 then inc(ly);
                if ly mod 2=0 then ly:=0;
        end;
        close(f1);
        if lx=ly then write(f2,lx) else write(f2,-1);
        close(f2);
end;
begin
        rd;
end.

var i,a,b,n,k,l,h:integer;
begin
read(n);
k:=0;
l:=0;
h:=0;
for i:=1 to n do begin
read(a,b);
k:=k+a;
l:=l+b;
if (a mod 2<>b mod 2) then h:=1;
end;
if (k mod 2=0)and(l mod 2=0) then write(0);
if (k mod 2=1)and(l mod 2=1)and(h=1) then write(1);
if (k mod 2<>0)and(l mod 2<>0)and(h=0) then write(-1);
end.

program zada;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
n,x,y,i,t,a,b:integer;
begin
readln(n);
t:=0;
for i:=1 to n do begin
readln(a,b);
x:=x+a;
y:=y+b;
if ((a mod 2)<>0)and((b mod 2)<>0) then t:=1;
end;
if ((x mod 2)=0)and((y mod 2)=0) then begin
                                       writeln('0');
                                       exit;
                                       end;
if (((x mod 2)=0)and((y mod 2)<>0))or(((x mod 2)<>0)and((y mod 2)=0)) then begin
                                                                            writeln('-1');
                                                                            exit;
                                                                            end;
if ((x mod 2)<>0) and ((y mod 2)<>0) then begin
                                          if t=1 then begin
                                                      writeln('-1');
                                                      exit;
                                                      end
                                          else begin
                                               writeln('1');
                                               end;
                                          end;
end.

{$mode objfpc}
var
        i, n, uple, both, nguale: integer;
        x, y: array[1..101] of integer;

begin
        readln(n);
        for i := 1 to n do
        begin
                readln(x[i], y[i]);
                if odd(x[i]) then inc(nguale);
                if odd(y[i]) then inc(uple);
                if odd(x[i]) and odd(y[i]) then inc(both);

        end;
        if (nguale mod 2 = 0) and (uple mod 2 = 0) then
        begin
                writeln(0);
                exit;
        end;

        if ((nguale+uple) mod 2 <> 0) or (both mod 2 <> 0) then writeln(-1) else
        writeln(1);
end.

Program _353A;
var
  n, i, x, y, a, b, a1, b1, c : longint;
begin
  read(n);
  a := 0; b := 0; c := 0;
  for i := 1 to n do
    begin
      read(x, y);
      if x mod 2 = 0
         then begin
                if y mod 2 = 1
                   then inc(a);
              end
         else if y mod 2 = 0
                 then inc(b)
                 else inc(c);
    end;
  a1 := a; b1 := b;
  a := a mod 2;
  b := b mod 2;
  c := c mod 2;

  if c = 0
     then if a = b
             then if a = 0
                     then write(0)
                     else write(1)
             else write(-1)
     else if (a + b = 1) or (a + b = 0) and (a1 + b1 > 0)
             then write(1)
             else write(-1);
end.

var x0,y0,x,y,c:integer;
    i,n:integer;

begin
  readln(n);
  for i:=1 to n do
    begin
      readln(x,y);
      if x mod 2 = 1 then inc(x0);
      if y mod 2 = 1 then inc(y0);
      if (x mod 2 = 1)and(y mod 2 = 1)
        then inc(c);
    end;
  //writeln(x0,' ',y0);
  if ((x0 mod 2 <> 0)xor(y0 mod 2 <> 0))
     or(((x0+y0+c) mod 2 = 1)and(x0 mod 2 <> 0)and(y0 mod 2 <> 0))
    then
      begin
        writeln(-1);
        exit;
      end;
  if (x0 mod 2 = 0)and(y0 mod 2 = 0)
    then writeln(0)
    else writeln(1);
end.

var n,i,x,y,t,s1,s2:integer;
begin
  t:=0;
  readln(n);
  s1:=0;
  s2:=0;
  for i:=1 to n do
    begin
      readln(x,y);
      s1:=x;
      s2:=y;
      if (x+y) mod 2=1 then t:=1;
    end;
  if (s1+s2) mod 2=1 then writeln(-1) else
    begin
      if (s1 mod 2=0) then writeln(0) else
        begin
          if t=1 then writeln(1) else writeln(-1);
        end;
    end;
end.

var i,n,x,y, a,b: LongInt;
begin
  Readln(n);
  for i:=1 to n do
  begin
    Readln(x,y);
    if (odd(x)) and (not odd(y)) or (not odd(x)) and (odd(y)) then inc(a);
    if (odd(x)) and (odd(y)) then inc(b);
  end;

  if odd(a) or (a=0) and (odd(b)) then Writeln('-1') else
  if odd(b) or (b=0) then Writeln('1') else Writeln('0');
end.

{$mode objfpc}
var
        i, n, uple, both, nguale: integer;
        x, y: array[1..101] of integer;

begin
        readln(n);
        for i := 1 to n do
        begin
                readln(x[i], y[i]);
                if odd(x[i]) then inc(nguale);
                if odd(y[i]) then inc(uple);
                if odd(x[i]) and odd(y[i]) then inc(both);

        end;
        if (nguale mod 2 = 0) and (uple mod 2 = 0) then
        begin
                writeln(0);
                exit;
        end;

        if ((nguale - uple) mod 2 <> 0) and (n<>1) then writeln(-1) else
        writeln(1);
end.

Var i,x,y,kn1,kn2,kch1,kch2,n:longint;
begin
     //assign (input,'input.txt'); reset (input);
     //assign (output,'output.txt'); rewrite (output);
     readln (n);
     kn1:=0;
     kn2:=0;
     kch1:=0;
     kch2:=0;
     for i:=1 to n do begin
     readln (x,y);
     if x mod 2=1
     then inc(kn1)
     else inc(kch2);
     if y mod 2=1
     then inc(kn2)
     else inc(kch2);
     end;
     if (kn1 mod 2=0) and (kn2 mod 2=0)
     then begin
          writeln (0);
          exit;
          end;
     if kn1 mod 2=1
     then begin
          if (kn2+1) mod 2=0
          then begin
               writeln (1);
               exit;
               end
          else begin
               writeln (-1);
               exit;
               end;
          end;
     if ((kn1 mod 2=0) and (kn2 mod 2=1)) or ((kn1 mod 2=1) and (kn2 mod 2=0))
     then begin
          writeln (-1);
          exit;
          end;
end.

var x0,y0,x,y:integer;
    i,n:integer;

begin
  readln(n);
  for i:=1 to n do
    begin
      readln(x,y);
      if x mod 2 = 1 then inc(x0);
      if y mod 2 = 1 then inc(y0);
    end;
  //writeln(x0,' ',y0);
  if ((x0 mod 2 <> 0)xor(y0 mod 2 <> 0))or((x=y)and(x0 mod 2 <> 0)and(y0 mod 2 <> 0))
    then
      begin
        writeln(-1);
        exit;
      end;
  if (x0 mod 2 = 0)and(y0 mod 2 = 0)
    then writeln(0)
    else writeln(1);
end.

var i,a,b,n,k,l,h:integer;
begin
read(n);
k:=0;
l:=0;
h:=0;
for i:=1 to n do begin
read(a,b);
k:=k+a;
l:=l+b;
if (a mod 2<>b mod 2) then h:=1;
end;
if (k mod 2=0)and(l mod 2=0) then write(0);
if (k mod 2=1)and(l mod 2=1)and(h=1) then write(1);
if ((k mod 2<>0)or(l mod 2<>0))and(h=0) then write(-1);
end.

var
a,b,n,i,x,y:longint;
begin
  readln(n);
  for i:=1 to n do
     begin
       readln(x,y);
       if (x mod 2)<>0 then inc(a);
       if (y mod 2)<>0 then inc(b);
     end;
  if (a=0)  and (b=0) then begin
                             writeln(0);
                             exit;
                           end;
  if (a+b)mod 2<>0 then begin
                         writeln(-1);
                         exit;
                       end;
  if (a>b) then begin
                  writeln(a);
                end
  else writeln(b);
end.

var i,n,x,y, a,b: LongInt;
begin
  Readln(n);
  for i:=1 to n do
  begin
    Readln(x,y);
    if (odd(x)) and (not odd(y)) or (not odd(x)) and (odd(y)) then inc(a);
    if (odd(x)) and (odd(y)) then inc(b);
  end;

  if odd(a) or (a=0) and (odd(b)) then Writeln('-1') else
  if ((a=0) and (b=0)) or (a=0) and (not odd(b)) or (not odd(a)) and (not odd(b)) then Writeln('0') else
  if odd(b) or (b=0) then Writeln('1');
end.

{$mode objfpc}
var
        i, n, uple, both, nguale: integer;
        x, y: array[1..101] of integer;

begin
        readln(n);
        for i := 1 to n do
        begin
                readln(x[i], y[i]);
                if odd(x[i]) then inc(nguale);
                if odd(y[i]) then inc(uple);
                if odd(x[i]) and odd(y[i]) then inc(both);

        end;
        if (nguale mod 2 = 0) and (uple mod 2 = 0) then
        begin
                writeln(0);
                exit;
        end;

        if (nguale + uple - both) mod 2 = 1 then writeln(-1) else
        writeln(1);
end.

program Project8;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n, i, nUp, nDown: Byte;
  nChangingDices:Boolean;
  nUpSum, nDownSum:SmallInt;
  inStr: string;

function ExtractNextNum(s: string):string;
begin
  Result := Copy(inStr,1,Pos(' ', inStr)-1);
  Delete(inStr,1,Pos(' ', inStr));
end;

begin

  nChangingDices:=false; //наличие костей, меняющих четность
  nUpSum:=0;
  nDownSum:=0;
  Readln(n);

  for i:=1 to n do
    begin
      Readln(instr);
      inStr := inStr + ' ';
      nUp := StrToInt(ExtractNextNum(inStr));
      nDown := StrToInt(ExtractNextNum(inStr));
      if (not nChangingDices) and (((nUp+nDown) mod 2)<>0) then nChangingDices:=true;
      nUpSum := nUpSum + nUp;
      nDownSum := nDownSum + nDown;
    end;

  if ((nUpSum mod 2)=0) and ((nDownSum mod 2)=0) then Writeln(0) //верх низ четные
  else if ((nUpSum+nDownSum) mod 2) <> 0 then Writeln(-1)   //четное что-то одно (верх или низ) - без вариантов
       else if ((nUpSum mod 2)<>0) and ((nDownSum mod 2)<>0) and nChangingDices then writeln(1); //верх и низ нечетные, при наличии
                                                                                //"меняющей" (чет/нечет) кости

  readln;

end.

var i,n,x,y,s, np, pr, l, p: LongInt;
begin
  Readln(n);
  for i:=1 to n do
  begin
    Readln(x,y);
    if (odd(x)) and (not odd(y)) then inc(l);
    if (not odd(x)) and (odd(y)) then inc(p);
    if odd(x) then inc(np) else inc(pr);
  end;

  if (l+p) mod 2 = 0 then Writeln((l+p) div 2) else Writeln('-1');
end.

var x0,y0,x,y:integer;
    i,n:integer;

begin
  readln(n);
  for i:=1 to n do
    begin
      readln(x,y);
      if x mod 2 = 1 then inc(x0);
      if y mod 2 = 1 then inc(y0);
    end;
  writeln(x0,' ',y0);
  if (x0+y0) mod 2 <> 0
    then
      begin
        writeln(-1);
        exit;
      end;
  if (x0 mod 2 = 0)and(y0 mod 2 = 0)
    then writeln(0)
    else writeln(1);
end.

var n,a,b,i,c1,c2:integer;
begin
read(n);
c1:=0;
c2:=0;
for i:=1 to n do begin
read(a,b);
c1:=c1+a;
c2:=c2+b;
end;
if (c1 mod 2=0) and (c2 mod 2=0) then write('0')
else begin
if (c1 mod 2=0) and (c2 mod 2=1) then write('-1');
if (c1 mod 2=1) and (c2 mod 2=0) then write('-1');
if (c1 mod 2=1) and (c2 mod 2=1) then write('1');
end;
end.

var sum1,sum2,ans,i,n:integer;
    a:array [1..100,1..2] of integer;
begin
 readln(n);
 for i:=1 to n do begin
  readln(a[i,1],a[i,2]);
  inc(sum1,a[i,1]);
  inc(sum2,a[i,2]);
 end;

 if ((sum1 mod 2 = 1) and (sum2 mod 2 = 0)) or ((sum1 mod 2 = 0) and (sum2 mod 2 = 1)) then
  writeln(-1)
 else
  if (sum1 mod 2 = 0) and (sum2 mod 2 = 0) then
   writeln(0)
  else
   for i:=1 to n do
    if ((a[i,1] mod 2 = 1) and (a[i,2] mod 2 = 0)) or ((a[i,1] mod 2 = 0) and (a[i,2] mod 2 = 1)) then begin
     writeln(1);
     exit;
    end;

end.

var i,a,b,n,k,l,h:integer;
begin
read(n);
k:=0;
l:=0;
h:=0;
for i:=1 to n do begin
read(a,b);
k:=k+a;
l:=l+b;
if (a mod 2<>b mod 2) then h:=1;
end;
if (k mod 2=0)and(l mod 2=0) then write(0);
if (k mod 2=1)and(l mod 2=1)and(h=1) then write(1);
if (k mod 2<>0)and(l mod 2<>0)and(h=0) then write(-1);
end.

var n,i,a,b,s1,s2:byte;
begin
    readln(n); s1:=0; s2:=0;
    for i:=1 to n do
    begin
        readln(a,b);
        if (a mod 2<>b mod 2) then inc(s1);
        if (a mod 2=1) and (b mod 2=1) then inc(s2);
    end;
    if (s1 mod 2=1) or (s2 mod 2=1) then writeln(-1) else writeln((s1+s2) div 2);
end.

var i,a,b,n,k,l,h:integer;
begin
read(n);
k:=0;
l:=0;
h:=0;
for i:=1 to n do begin
read(a,b);
k:=k+a;
l:=l+b;
if (a mod 2<>b mod 2) then h:=1;
end;
if (k mod 2=0)and(l mod 2=0) then write(0);
if (k mod 2=1)and(l mod 2=1)and(h=1) then write(1);
if k mod 2<>l mod 2 then write(-1);
end.

var n,a,b,i,c1,c2,k:integer;
begin
read(n);
c1:=0;
c2:=0;
k:=0;
for i:=1 to n do begin
read(a,b);
c1:=c1+a;
c2:=c2+b;
if a=b then k:=k+1;
end;
if (c1 mod 2=0) and (c2 mod 2=0) then write('0')
else begin
if (c1 mod 2=0) and (c2 mod 2=1) then write('-1');
if (c1 mod 2=1) and (c2 mod 2=0) then write('-1');
if (c1 mod 2=1) and (c2 mod 2=1) and (n>1) and (k<>n) then write('1');
if (c1 mod 2=1) and (c2 mod 2=1) and (n>1) and (k=n) then write('-1');
if (c1 mod 2=1) and (c2 mod 2=1) and (n=1) then write('-1');
end;
end.

var
a,b:array[1..101] of integer;
i,n,q,w:integer;
begin
readln(n);
q:=0;
w:=0;
for i:= 1 to n do begin
readln(a[i],b[i]);
q:=q+a[i];w:=w+b[i];end;
if (q mod 2 = 0)and( w mod 2 = 0) then writeln('0');
if (q mod 2 = 0)and( w mod 2 = 1) then writeln('-1');
if (q mod 2 = 1)and( w mod 2 = 0) then writeln('-1');
if (q mod 2 = 1)and( w mod 2 = 1) then writeln('1');
end.

var nn1,nn2,n,i,a,b,n1,n2,j:longint;
Begin
 readln(n);
 for i:=1 to n do
  begin
   readln(a,b);
   if (a mod 2<>0)and(b mod 2<>0) then inc(j);
   if a mod 2<>0 then inc(n1);
   if b mod 2<>0 then inc(n2);
  end;
 if abs(n1-n2)mod 2<>0 then begin writeln(-1);halt; end;
 nn1:=n1-j;nn2:=n2-j;
 if (n1 mod 2=0)and(n2 mod 2=0) then writeln(0) else
 if ((n1 mod 2<>0)and(nn1=0))or((n2 mod 2<>0)and(nn2=0)) then writeln(-1) else
 writeln(1);
End.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='x';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,rr:array[0..1000000]of longint;
    qc:array[0..2000,0..2000]of int64;
    ss:array[0..1000]of string;
    s,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    res,cur:int64;
    aa,bb,u,v,nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;
    test,ll,t,tt:longint;
    b,bbb,b0,b1,b2,b3:boolean;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

function gcd(q,c:int64):int64;
  begin
  while ((q>0)and(c>0)) do
    if q>c then q:=q mod c else c:=c mod q;
  if q>0 then gcd:=q else gcd:=c;
  end;

procedure run;
var i,j,k,z,d,i0,i1,i2:longint;
    r,m,x:int64;
  begin
  //init;
  readln(n);
  q:=0;
  c:=0;
  k:=0;
  m:=0;
  for i:=1 to n do
    begin
    read(q0,c0);
    if not(odd(q0)) then m:=1;
    if not(odd(c0)) then m:=1;
    if (odd(q0+c0)) then inc(k);
    inc(q,q0); inc(c,c0);
    end;
  if ((odd(q))and(odd(c))and(m=0)) then writeln('-1') else
  if odd(q+c) then writeln('-1') else
  if ((q mod 2=0)and(c mod 2=0)) then writeln('0') else
  if k=0 then writeln('2') else writeln('1');
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.

var x0,y0,x,y:integer;
    i,n:integer;

begin
  readln(n);
  for i:=1 to n do
    begin
      readln(x,y);
      if x mod 2 = 1 then inc(x0);
      if y mod 2 = 1 then inc(y0);
    end;
  //writeln(x0,' ',y0);
  if ((x0 mod 2 <> 0)xor(y0 mod 2 <> 0))or((x=y)and(x0 mod 2 <> 0)and(y0 mod 2 <> 0))
    then
      begin
        writeln(-1);
        exit;
      end;
  if (x0 mod 2 = 0)and(y0 mod 2 = 0)
    then writeln(0)
    else writeln(1);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
    SysUtils;

var
    n, i, a, b, two, x, y, t: integer;
procedure bad();
begin
    writeln(-1);
    halt(0);
end;
begin
    readln(n);
    two := 0;
    a := 0;
    b := 0;
    for i := 1 to n do
    begin
        readln(x, y);
        t := x mod 2 + y mod 2;
        if (t = 2) then
            inc(two)
        else
        if (t = 1) then
        begin
            if (x mod 2 = 1) then
                inc(a)
            else
                inc(b);
        end;
    end;
    two := two mod 2;
    dec(a, two);
    dec(b, two);
    if (a mod 2 = 0) and (b mod 2 = 0) then
        writeln(0)
    else
    if ((a + b) mod 2 = 0) then
        writeln(1)
    else
        bad;
    readln;
    readln;
end.

var
  n,i,x,y,temp,upsum,downsum:longint;
begin
  read(n);
  for i:=1 to n do
    begin
      read(x,y);
      inc(upsum,x);
      inc(downsum,y);
      if (x + y) mod 2 =1 then
        temp:=1;
    end;
  if (upsum+downsum) mod 2 = 0then
    if upsum mod 2 = 0 then
      write(temp)
    else if temp = 1 then
      write(1)
    else
      write(-1)
  else
    write(-1);
end.

var n,i,p,p1:longint;a,b:array[1..1000] of longint;
begin
read(n);
for i:=1 to n do   begin
read(a[i],b[i]);
p:=p+ a[i] mod 2;
p1:=p1+ b[i] mod 2;
end;
If p mod 2=0 then begin
 if p1 mod 2=0 then writeln(0)  else writeln(-1)
 end else
 if p1 mod 2=1 then writeln(1) else
writeln(1);
end.

var x0,y0,x,y:integer;
    i,n:integer;

begin
  readln(n);
  for i:=1 to n do
    begin
      readln(x,y);
      if x mod 2 = 1 then inc(x0);
      if y mod 2 = 1 then inc(y0);
    end;
  //writeln(x0,' ',y0);
  if (x0 mod 2 <> 0)and(y0 mod 2 <> 0)
    then
      begin
        writeln(-1);
        exit;
      end;
  if (x0 mod 2 = 0)and(y0 mod 2 = 0)
    then writeln(0)
    else writeln(1);
end.

uses math;
var     i,n,sol,temp:longint; x,y:array[1..1000] of longint;
 begin
  read(n);
   for i:=1 to n do
        begin
                read(x[i],y[i]);
                sol:=sol+x[i];
                temp:=temp+y[i];
        end;

  if (sol mod 2=0) and (temp mod 2=0) then
    begin
     write(0);
    exit;
  end ;
  if (n=1) and (sol mod 2=0) and (temp mod 2=0)  then
   begin
    writeln(0);
   exit;
  end;
  if (n=1) and (((sol mod 2<>0) and (temp mod 2=0)) or((sol mod 2=0) and (temp mod 2<>0) )) then
   begin
    writeln(-1);
   exit;
  end;

 if (sol mod 2<>0)and (temp mod 2<>0 ) then
    for i:=1 to n do
      if  (((x[i] mod 2<>0) and (y[i] mod 2=0) )or ((x[i] mod 2=0) and (y[i] mod 2<>0)))then
       begin

        writeln(1);
       exit;
      end

     else
      begin
       writeln(-1);
      exit;
     end;

  end  .

program domino;
var n,sb,sa,i:longint;
    a,b:byte;
    f:boolean;
BEGIN
sb:=0;
sa:=0;
f:=false;
readln(n);
for i:=1 to n do
  begin
  readln(a,b);
  sb:=sb+b;
  sa:=sa+a;
  if (a+b) mod 2=1 then f:=true;
  end;
if n=1
  then
  if (sa mod 2=0) and (sb mod 2=0)
    then
    begin
    write('0');
    exit;
    end
    else
    begin
    write('-1');
    exit;
    end;
if (sa mod 2=0) and (sb mod 2=0)
  then
  begin
  write('0');
  exit;
  end;
if (sa mod 2=1) and (sb mod 2=1)
  then
  if f
    then
    begin
    write('1');
    exit;
    end
	else
	begin
	write('-1');
	exit;
	end;
if f
  then
  begin
  write('1');
  exit;
  end
  else
  begin
  write('-1');
  exit;
  end;
END.

var
     N,Kol,Sum1,Sum2,X,Y:Int64;
     i:Longint;
begin
     Readln(N);
     for i:=1 to N do
begin
     Read(X,Y);
     if ((X mod 2=0) and (Y mod 2=1)) or
     ((X mod 2=1) and (Y mod 2=0)) then Inc(Kol);
     Inc(Sum1,X);
     Inc(Sum2,Y);
 end;
     if (Sum1 mod 2=0) and (Sum2 mod 2=0) then Writeln('0')
                                          else
     if ((Sum1 mod 2=1) and (Sum2 mod 2=0)) or ((Sum1 mod 2=0) and (Sum2 mod 2=1)) then Writeln('-1')
                                                                                else
     if Kol>0 then Writeln('1');
 end.

var
a,b:array[1..101] of integer;
i,n,q,w:integer;
begin
readln(n);
q:=0;
w:=0;
for i:= 1 to n do begin
readln(a[i],b[i]);
q:=q+a[i];w:=w+b[i];end;
if (q=1)and(w=1)then begin writeln('-1');exit;end;
if (q mod 2 = 0)and( w mod 2 = 0) then writeln('0');
if (q mod 2 = 0)and( w mod 2 = 1) then writeln('-1');
if (q mod 2 = 1)and( w mod 2 = 0) then writeln('-1');
if (q mod 2 = 1)and( w mod 2 = 1) then writeln('1');
end.

Var n,sa,sb,i:integer;
    a,b:array [1..101] of integer;
begin
     readln(n);
     for i:=1 to n do
      readln(a[i],b[i]);
     for i:=1 to n do
      begin
       sa:=sa+a[i];
       sb:=sb+b[i];
      end;
     if (sa+sb) mod 2 = 1 then write('-1')
     else if (sa mod 2 = 0) and (sb mod 2 = 0) then write('0')
     else if (sa mod 2 = 1) and (sb mod 2 = 1) then write('1');
end.

const   fi='';
        fo='';
var     f,g:Text;
        i,n,tong,tongl,tongr,a,b:longint;
begin
        assign(f,fi);
        reset(f);
        assign(G,fo);
        rewrite(g);
        readln(f,n);
        tong:=0;
        tongl:=0;
        tongr:=0;
        for i:=1 to n do
        begin
                readln(F,a,b);
                inc(tong,a+b);
                inc(tongl,a);
                inc(tongr,b);
        end;
        close(F);

        if tong mod 2 <> 0 then writeln(G,-1)
                else if (tongl mod 2 <> 0) or (tongr mod 2 <> 0) then writeln(g,1) else writeln(G,0);
        close(G);
end.

var nn1,nn2,n,i,a,b,n1,n2,j:longint;
Begin
 readln(n);
 for i:=1 to n do
  begin
   readln(a,b);
   if (a mod 2<>0)and(b mod 2<>0) then inc(j);
   if a mod 2<>0 then inc(n1);
   if b mod 2<>0 then inc(n2);
  end;
 nn1:=n1-j;nn2:=n2-j;
 if (n1 mod 2=0)and(n2 mod 2=0) then writeln(0) else
 if ((n1 mod 2<>0)and(nn1=0))or((n2 mod 2<>0)and(nn2=0)) then writeln(-1) else
 if (n1 mod 2<>0)and(n2 mod 2<>0) then writeln(1) else
 if abs(n1-n2)mod 2<>0 then begin writeln(-1);halt; end;
End.

program za;

var
  a,b:array [1..100] of boolean;
  n,i,x,y,sumn1,sumn2,sumv1,sumv2:longint;

begin
  readln(n);
  for i:=1 to n do
  begin
    read(x,y);
    if x mod 2 = 0 then a[i]:=true
    else a[i]:=false;
    if y mod 2 = 0 then b[i]:=true
    else b[i]:=false;
  end;
  for i:=1 to n do
  begin
    if a[i] then inc(sumv2)
    else inc (sumv1);
    if b[i] then inc(sumn2)
    else inc (sumn1);
  end;
  if (sumn1=0) and (sumv1=0) then
  begin
     writeln(0);
     halt(0);
  end;
  if (sumn1=0) and (sumv1 mod 2 <> 0) then
  begin
    writeln(-1);
    halt(0);
  end;
  if (sumv1=0) and (sumn1 mod 2 <> 0) then
  begin
    writeln(-1);
    halt(0);
  end;
  if (sumn1 mod 2 <> 0) and (sumv1 mod 2 <> 0) then
  begin
    writeln(1);
    halt(0);
  end;
  if (n<=1) and ((sumv2<>1) or (sumn2<>1)) then
  begin
    writeln(-1);
    halt(0);
  end;
  writeln(0);
end.

var x,y,n,i,s1,s2,f:integer;
    s:array[1..100] of integer;
begin
readln(n);
s1:=0;
s2:=0;
f:=0;
for i:=1 to n do
  begin
  readln(x,y);
  s1:=s1+x;
  s2:=s2+y;
  s[i]:=x+y;
  end;
if (s1 mod 2=0) and (s2 mod 2=0) then begin writeln('0'); halt; end;
if ((s1 mod 2=0) and (s2 mod 2<>0)) or ((s1 mod 2<>0) and (s2 mod 2=0)) then begin writeln('-1'); halt; end;
for i:=1 to n do
  begin
  if s[i] mod 2<>0 then f:=1;
  end;
if f=1 then writeln('1');
end.

var n,a,b,i,c1,c2:integer;
begin
read(n);
c1:=0;
c2:=0;
for i:=1 to n do begin
read(a,b);
c1:=c1+a;
c2:=c2+b;
end;
if (c1 mod 2=0) and (c2 mod 2=0) then write('0')
else begin
if (c1 mod 2=0) and (c2 mod 2=1) then write('-1');
if (c1 mod 2=1) and (c2 mod 2=0) then write('-1');
if (c1 mod 2=1) and (c2 mod 2=1) then write('1');
end;
end.

var
   n,k,sx,sy,i : integer;
   x,y,s : array [1..100] of byte;
begin
   read(n);
   for i:=1 to n do
      begin
         read(x[i],y[i]);
         sx:=sx+x[i];
         sy:=sy+y[i];
         s[i]:=x[i]+y[i];
      end;
   if ((sx+sy) mod 2=1) then
      begin
         writeln(-1);
         exit;
      end;
   if (sx mod 2=1) then
      begin
         for i:=1 to n do
            if s[i] mod 2=1 then
               begin
                  writeln(1);
                  exit;
               end;
         writeln(-1);
      end;
   writeln(0);
end.

{$APPTYPE CONSOLE}

uses
  SysUtils,math;
  const in_file='input.txt';
  const out_file='output.txt';
  var
  i,j,n,m,k,ans,x,y,p:longint;
   a:array[0..1] of integer;

begin
//assign(input,in_file); reset(input);
//assign(output,out_file); rewrite(output);
  fillchar(a,sizeof(a),0);
  readln(n);
  p:=0;
  for i:=1 to n do
  begin
  readln(x,y);
  if ((x and 1)=1)and((y and 1)=1) then  begin a[1]:=a[1]+1; a[0]:=a[0]+1; continue; end;
  if ((x and 1)=(y and 1)) then continue;
  if ((x and 1)=1) then a[0]:=a[0]+1 else a[1]:=a[1]+1;
  end;
  if (((a[0]+a[1]) and 1)=1)  then begin writeln(-1); readln; halt; end;
  if (a[0]=0)or(a[1]=0)or((a[1] and 1)=0) then writeln(0) else writeln(1);
  readln;

//close(output);
//close(input);
end.

Program adomino;

var
	x : array[1..100] of integer;
	y : array[1..100] of integer;
	i, a, b, n : integer;

begin
	readln(n); a := 0; b := 0;
	for i:=1 to n do
	begin
		readln(x[i], y[i]);
		a := a + x[i];
		b := b + y[i];
	end;
	a := a mod 2;
	b := b mod 2;
	if (((a = 1) and (b = 0)) or ((a = 0) and (b = 1))) then writeln(-1)
	else if ((a = 1) and (b = 1)) then writeln(1)
	else {(a = 0) and (b = 0)} writeln(0);
end.

uses math;

var n           : int64;
    i,j         : longint;
    x,y         : longint;
    cnt,ans     : longint;
    a           : array[1..1000] of longint;
    s,s1,s2     : ansistring;

begin
     readln(n);

     for i := 1 to n do
     begin
          readln(x,y);
          if (x+y) mod 2 = 1
          then cnt := 1;

          a[1] := a[1] + x;
          a[2] := a[2] + y;
     end;

     if (a[1] mod 2 = 0) AND (a[2] mod 2 = 0)
     then writeln(0);

     if (a[1] mod 2 = 1) AND (a[2] mod 2 = 1) AND (cnt = 1)
     then writeln(1);

     if ((a[1]+a[2]) mod 2 = 1)
     then writeln(-1);
end.

var
    i, j                   :longint;
    n                       :longint;
    x, y                    :array[0..110] of longint;
    flag                    :array[0..110] of boolean;
    tot, ans                :longint;
    tot11, tot01, tot10     :longint;
    f                       :boolean;

begin
    read(n);
    for i:=1 to n do read(x[i],y[i]);
    for i:=1 to n do
    begin
        x[i]:=x[i] mod 2;
        y[i]:=y[i] mod 2;
    end;

    for i:=1 to n do if (x[i]=0) and (y[i]=0) then flag[i]:=true;

    for i:=1 to n do if not flag[i] then
        if (x[i]=0) and (y[i]=1) then
        for j:=1 to n do if (not flag[j]) and (i<>j) then
        if (x[j]=0) and (y[j]=1) then
        begin
            flag[i]:=true;
            flag[j]:=true;
            break;
        end;

    for i:=1 to n do if not flag[i] then
        if (x[i]=1) and (y[i]=1) then
        for j:=1 to n do if (not flag[j]) and (i<>j) then
        if (x[j]=1) and (y[j]=1) then
        begin
            flag[i]:=true;
            flag[j]:=true;
            break;
        end;

    for i:=1 to n do if not flag[i] then
        if (x[i]=1) and (y[i]=0) then
        for j:=1 to n do if (not flag[j]) and (i<>j) then
        if (x[j]=1) and (y[j]=0) then
        begin
            flag[i]:=true;
            flag[j]:=true;
            break;
        end;
    tot:=0;
    for i:=1 to n do if not flag[i] then
        if (x[i]=0) and (y[i]=1) then inc(tot01) else
        if (x[i]=1) and (y[i]=0) then inc(tot10) else
        if (x[i]=1) and (y[i]=1) then inc(tot11);

   if (tot11=1) and (tot01=1) and (tot10=1) then writeln(0) else
   if (tot11=1) and (tot01=1) and (tot10=0) then writeln(-1) else
   if (tot11=1) and (tot10=1) and (tot01=0) then writeln(-1) else
   if (tot11=1) and (tot01=0) and (tot10=0) then writeln(-1) else
   if (tot01=1) and (tot10=1) then writeln(1) else
   if (tot01=0) and (tot10=0) then writeln(0) else writeln(-1);
end.

var n,i,a,b,n1,n2,j:longint;
Begin
 readln(n);
 for i:=1 to n do
  begin
   readln(a,b);
   if (a mod 2<>0)and(b mod 2<>0) then inc(j);
   if a mod 2<>0 then inc(n1);
   if b mod 2<>0 then inc(n2);
  end;
 if abs(n1-n2)mod 2<>0 then begin writeln(-1);halt; end;
 if ((n1=j)or(n2=j))and(j<>0) then begin writeln(-1);halt;end;
 if (n1 mod 2=0)and(n2 mod 2=0) then writeln(0) else writeln(1);
End.

{$mode objfpc}
var
        i, n, uple, both, nguale: integer;
        x, y: array[1..101] of integer;

begin
        readln(n);
        for i := 1 to n do
        begin
                readln(x[i], y[i]);
                if odd(x[i]) then inc(nguale);
                if odd(y[i]) then inc(uple);
                if odd(x[i]) and odd(y[i]) then inc(both);

        end;
        if (nguale mod 2 = 0) and (uple mod 2 = 0) then
        begin
                writeln(0);
                exit;
        end;

        if (nguale - uple) mod 2 <> 0 then writeln(-1) else
        writeln(1);
end.

var n,i,a,b,s1,s2:byte;
begin
    readln(n); s1:=0; s2:=0;
    for i:=1 to n do
    begin
        readln(a,b); inc(s1,a); inc(s2,b);
    end;
    if ((s1+s2) mod 2=1) then writeln(-1) else
    begin
        if (s1 mod 2=0) then writeln(0) else writeln(1);
    end;
end.

var
  n,i,x,y,temp,upsum,downsum:longint;
begin
  read(n);
  for i:=1 to n do
    begin
      read(x,y);
      inc(upsum,x);
      inc(downsum,y);
      if (x + y) mod 2 =1 then
        temp:=1;
    end;
  if (upsum+downsum) mod 2 = 0then
    write(temp);
  if (upsum + downsum) mod 2 = 1 then
    write(-1);
end.

program za;

var
  a,b:array [1..100] of boolean;
  n,i,x,y,sumn1,sumn2,sumv1,sumv2:longint;

begin
  readln(n);
  for i:=1 to n do
  begin
    read(x,y);
    if x mod 2 = 0 then a[i]:=true
    else a[i]:=false;
    if y mod 2 = 0 then b[i]:=true
    else b[i]:=false;
  end;
  for i:=1 to n do
  begin
    if a[i] then inc(sumv2)
    else inc (sumv1);
    if b[i] then inc(sumn2)
    else inc (sumn1);
  end;
  if (sumn1=0) and (sumv1=0) then
  begin
     writeln(0);
     halt(0);
  end;
  if (sumn1=0) and (sumv1 mod 2 <> 0) then
  begin
    writeln(-1);
    halt(0);
  end;
  if (sumv1=0) and (sumv1 mod 2 <> 0) then
  begin
    writeln(-1);
    halt(0);
  end;
  if (sumn1 mod 2 <> 0) and (sumv1 mod 2 <> 0) then
  begin
    writeln(1);
    halt(0);
  end;
  if (n<=1) and ((sumv2<>1) or (sumn2<>1)) then
  begin
    writeln(-1);
    halt(0);
  end;
  writeln(0);
end.

Program _353A;
var
  n, i, x, y, a, b, c : longint;
begin
  read(n);
  a := 0; b := 0; c := 0;
  for i := 1 to n do
    begin
      read(x, y);
      if x mod 2 = 0
         then begin
                if y mod 2 = 1
                   then inc(a);
              end
         else if y mod 2 = 0
                 then inc(b)
                 else inc(c);
    end;
  a := a mod 2;
  b := b mod 2;
  c := c mod 2;

  if c = 0
     then if a = b
             then if a = 0
                     then write(0)
                     else write(1)
             else write(-1)
     else if a + b = 1
             then write(1)
             else write(-1);
end.