#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, s1, s2, m, n;
  cin >> n;
  m = 0;
  s1 = 0;
  s2 = 0;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    s1 += a;
    s2 += b;
    if ((a % 2 == 1) && (b % 2 == 0) || (a % 2 == 0) && (b % 2 == 1)) m = 1;
  }
  if ((s1 % 2 == 0) && (s2 % 2 == 0))
    cout << '0' << endl;
  else if ((s1 % 2 == 1) && (s2 % 2 == 1) && (m == 1))
    cout << '1' << endl;
  else
    cout << "-1" << endl;
  return 0;
}
