#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  scanf("%d", &n);
  int i;
  int sum1 = 0, sum2 = 0;
  int flag = 0;
  int temp1, temp2;
  for (i = 0; i < n; ++i) {
    scanf("%d %d", &temp1, &temp2);
    if ((temp1 % 2 == 0 && temp2 % 2 == 1) ||
        (temp1 % 2 == 1 && temp2 % 2 == 0))
      flag = 1;
    sum1 += temp1;
    sum2 += temp2;
  }
  if ((sum1 + sum2) % 2 == 1)
    printf("-1");
  else {
    if (sum2 % 2 == 0 && sum1 % 2 == 0)
      printf("0");
    else {
      if (flag)
        printf("1");
      else
        printf("-1");
    }
  }
  return 0;
}
