#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  vector<pair<int, int> > v;
  int sum1 = 0;
  int sum2 = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    v.push_back(make_pair(a, b));
    sum1 += a;
    sum2 += b;
  }
  if (sum1 % 2 == 0 && sum2 % 2 == 0) {
    cout << "0";
    return 0;
  }
  int sec = 0;
  for (int i = 0; i < v.size(); i++) {
    if (((sum1 - v[i].first) + v[i].second) % 2 == 0 &&
        ((sum2 - v[i].second) + v[i].first) % 2 == 0) {
      cout << "1";
      return 0;
    }
  }
  cout << "-1";
}
