#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int sumx, sumy;
  sumx = 0;
  sumy = 0;
  bool changer = false;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    sumx += x[i];
    sumy += y[i];
    if (x[i] % 2 != y[i] % 2) {
      changer = true;
    }
  }
  if (sumx % 2 == 0 && sumy % 2 == 0) {
    cout << 0;
  } else if (sumx % 2 != sumy % 2) {
    cout << -1;
  } else if (changer) {
    cout << 1;
  } else {
    cout << -1;
  }
  return 0;
}
