#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, vet[2][100], sumU = 0, sumL = 0, ans;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &vet[0][i], &vet[1][i]);
    sumU += vet[0][i];
    sumL += vet[1][i];
  }
  if ((sumU + sumL) % 2 == 1) {
    ans = -1;
  } else if (sumU % 2 == 0 && sumL % 2 == 0) {
    ans = 0;
  } else {
    ans = -1;
    for (int i = 0; i < n; i++) {
      if (vet[0][i] % 2 != vet[1][i] % 2) {
        ans = 1;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
