#include <bits/stdc++.h>
inline void swap(int &a, int &b) {
  a = a ^ b;
  b = a ^ b;
  a = a ^ b;
}
inline void smax(int &a, int b) {
  if (b > a) a = b;
}
inline void smin(int &a, int b) {
  if (b < a) a = b;
}
using namespace std;
inline int sgd(int a, int b) {
  if (a < b) swap(a, b);
  while (b > 0) {
    a -= a / b * b;
    swap(a, b);
  }
  return a;
}
int n;
int main() {
  cin >> n;
  int co = 0;
  bool l = 0;
  bool t = 0;
  for (int i = (0); i < (n); i++) {
    int x, y;
    cin >> x >> y;
    l ^= y & 1;
    t ^= x & 1;
    if ((x & 1) != (y & 1)) {
      co++;
    }
  }
  if (l != t)
    cout << -1;
  else if (l == 0 && t == 0)
    cout << 0;
  else if (co > 0)
    cout << 1;
  else
    cout << -1;
}
