#include <bits/stdc++.h>
int main() {
  int N, num1, num2;
  bool arr1[100], arr2[100], res1, res2, canSwap;
  scanf("%d", &N);
  res1 = res2 = canSwap = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &num1, &num2);
    arr1[i] = num1 & 1;
    arr2[i] = num2 & 1;
    res1 ^= arr1[i];
    res2 ^= arr2[i];
    canSwap |= (arr1[i] ^ arr2[i]);
  }
  if (!res1 && !res2)
    printf("0\n");
  else if (res1 != res2)
    printf("-1\n");
  else
    printf(canSwap ? "1\n" : "-1\n");
  return 0;
}
