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