#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x, y;
  int l = 0, r = 0, o = 0;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if (x % 2 == 0 && y % 2 == 1) {
      r++;
    } else if (y % 2 == 0 && x % 2 == 1) {
      l++;
    } else if (y % 2 == 1 && x % 2 == 1) {
      o++;
    }
  }
  if (l == 0 && r == 0 && o % 2 == 1) {
    cout << "-1";
  } else if ((o * 2 + l + r) % 2 == 1) {
    cout << "-1";
  } else {
    if (o % 2 == 0) {
      if (l % 2 == 0 && r % 2 == 0) {
        cout << "0";
      } else {
        cout << "1";
      }
    } else {
      if (l % 2 == 0 && r % 2 == 0) {
        cout << "1";
      } else {
        cout << "0";
      }
    }
  }
  return 0;
}
