#include <bits/stdc++.h>
using namespace std;
template <class T>
string toStr(const T &x) {
  stringstream s;
  s << x;
  return s.str();
}
template <class T>
int toInt(const T &x) {
  stringstream s;
  s << x;
  int r;
  s >> r;
  return r;
}
int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > v;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  int parimpar = 0, imparimpar = 0, parespares = 0, impa = 0, impb = 0;
  for (int i = 0; i < n; ++i) {
    if (v[i].first % 2 != 0 && v[i].second % 2 == 0 ||
        v[i].second % 2 != 0 && v[i].first % 2 == 0)
      parimpar++;
    if (v[i].first % 2 == 0 && v[i].second % 2 == 0) parespares++;
    if (v[i].second % 2 != 0 && v[i].first % 2 != 0) imparimpar++;
    if (v[i].first % 2 != 0) impa++;
    if (v[i].second % 2 != 0) impb++;
  }
  if (imparimpar == 0 && parimpar % 2 == 0 ||
      parimpar == 0 && imparimpar % 2 == 0) {
    if (impa % 2 == 0 && impb % 2 == 0)
      cout << 0;
    else
      cout << 1;
  } else if (parimpar && parimpar % 2 == 0 && imparimpar > 0) {
    if (impa % 2 == 0 && impb % 2 == 0)
      cout << 0;
    else
      cout << 1;
  } else
    cout << -1;
  return 0;
}
