#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long MOD = 998244353;
double eps = 1e-12;
void solve() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> up, down;
  long long t1, t2, s1 = 0, s2 = 0;
  for (long long i = 0; i < n; i++) {
    cin >> t1 >> t2;
    s1 += t1;
    s2 += t2;
    up.push_back(t1);
    down.push_back(t2);
  }
  if (s1 % 2 == 0 && s2 % 2 == 0) {
    cout << 0;
  } else if (s1 % 2 == 1 && s2 % 2 == 1 && n > 1) {
    for (long long i = 0; i < n; i++) {
      if (up[i] % 2 != down[i] % 2) {
        cout << 1;
        return 0;
      }
    }
    cout << -1;
  } else {
    cout << -1;
  }
  return 0;
}
