#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int sum1 = 0, sum2 = 0, t1 = 0, t2 = 0;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    sum1 += x;
    sum2 += y;
    if (x % 2 == 0 && y % 2 == 1)
      t1++;
    else if (x % 2 == 1 && y % 2 == 0)
      t2++;
  }
  if (sum1 % 2 == 0 && sum2 % 2 == 0)
    cout << "0";
  else if (sum1 % 2 == 1 && sum2 % 2 == 1 && (t1 > 0 || t2 > 0))
    cout << "1";
  else
    cout << "-1";
}
