#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<ii> vs(n);
  int s1 = 0, s2 = 0;
  for (auto &x : vs) {
    cin >> x.first >> x.second;
    s1 += x.first;
    s2 += x.second;
  }
  if (s1 % 2 == 0 and s2 % 2 == 0) {
    cout << 0 << endl;
    return 0;
  } else if (s1 % 2 == 1 and s2 % 2 == 1) {
    bool can = false;
    for (auto x : vs)
      if (x.first % 2 != x.second % 2) can = true;
    if (can)
      cout << 1 << endl;
    else
      cout << -1 << endl;
  } else {
    cout << -1 << endl;
  }
}
