#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a, b;
  int oddsChangeable[2] = {0, 0};
  int odds[2] = {0, 0};
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a % 2 == 1) {
      odds[0]++;
      if (b % 2 != 1) {
        oddsChangeable[0]++;
      }
    }
    if (b % 2 == 1) {
      odds[1]++;
      if (a % 2 != 1) {
        oddsChangeable[1]++;
      }
    }
  }
  if (odds[0] % 2 == 0 && odds[1] % 2 == 0) {
    cout << 0 << endl;
  } else if ((odds[0] % 2 == 0 && odds[1] % 2 == 1) ||
             (odds[0] % 2 == 1 && odds[1] % 2 == 0)) {
    cout << -1 << endl;
  } else if (odds[0] % 2 == 1 && odds[1] % 2 == 1) {
    if (oddsChangeable[0] > 0 || oddsChangeable[1] > 0) {
      cout << 1 << endl;
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}
