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