#include <bits/stdc++.h>
using namespace std;
int n, x[100005], y[100005], s1, s2;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    s1 += x[i];
    s2 += y[i];
  }
  if (s1 % 2 == 0 && s2 % 2 == 0) {
    cout << 0;
  } else {
    for (int i = 1; i <= n; i++) {
      s1 -= x[i];
      s1 += y[i];
      s2 -= y[i];
      s2 += x[i];
      if (s1 % 2 == 0 && s2 % 2 == 0) {
        cout << 1;
        return 0;
      }
      s1 -= y[i];
      s1 += x[i];
      s2 -= x[i];
      s2 += y[i];
    }
    cout << -1;
  }
}
