#include <bits/stdc++.h>
int main() {
  int N;
  int sum1 = 0;
  int sum2 = 0;
  int f = -1;
  scanf("%d", &N);
  int a, b;
  for (int i = 0; i < N; ++i) {
    scanf("%d%d", &a, &b);
    sum1 += a;
    sum2 += b;
    if ((a - b) % 2 != 0) f = 1;
  }
  if (sum1 % 2 == 0 && sum2 % 2 == 0)
    printf("0\n");
  else if ((sum1 % 2 != 0) && (sum2 % 2 != 0)) {
    printf("%d\n", f);
  } else {
    printf("-1\n");
  }
}
