#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int upperOdds = 0, downOdds = 0, diff = 0;
  for (int i = 0; i < (n); i++) {
    int up, down;
    cin >> up >> down;
    if (up % 2) upperOdds += 1;
    if (down % 2) downOdds += 1;
    if (up % 2 != down % 2) diff += 1;
  }
  if ((upperOdds + downOdds) % 2) {
    cout << -1;
  } else {
    if (upperOdds % 2 == 0 and downOdds % 2 == 0) {
      cout << 0;
    } else {
      if (diff) {
        cout << 1;
      } else {
        cout << -1;
      }
    }
  }
  return 0;
}
