#include <bits/stdc++.h>
const long long MAX = 1e6;
using namespace std;
const long long alpha = 26;
void solve() {
  long long n;
  cin >> n;
  long long left = 0, right = 0;
  long long count = 0;
  for (long long i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    left += a;
    right += b;
    if ((a + b) % 2 != 0) count++;
  }
  if (left % 2 == 0 && right % 2 == 0) {
    cout << 0 << "\n";
    return;
  }
  if (left % 2 != 0 && right % 2 != 0) {
    if (count > 0) {
      cout << 1;
      return;
    }
  }
  cout << -1;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
