#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long int INF = 1e18;
const int MOD = 1e9 + 7;
int main() {
  int n;
  scanf("%d", &n);
  int s1, s2;
  s1 = s2 = 0;
  bool Ok = false;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x % 2 != y % 2) Ok = true;
    s1 += x;
    s2 += y;
  }
  if (s1 % 2 == s2 % 2) {
    printf("%d\n", (s1 % 2 ? (Ok ? 1 : -1) : 0));
  } else
    printf("-1\n");
  return 0;
}
