#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, sumx = 0, sumy = 0, x, y, a, b, yes = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    sumx += x;
    sumy += y;
    if (x % 2 != y % 2) yes = 1;
  }
  a = sumx % 2;
  b = sumy % 2;
  if (a == b && a == 0)
    cout << "0";
  else if (a == b && a == 1 && n > 1 && yes)
    cout << "1";
  else
    cout << "-1";
}
