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