#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long a[n], b[n];
  long long sum = 0, tum = 0, cnt = 0, aod = 0, aev = 0, bod = 0, bev = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] % 2 == 0) aev++;
    if (a[i] % 2 == 1) aod++;
    if (b[i] % 2 == 0) bev++;
    if (b[i] % 2 == 1) bod++;
    sum += a[i];
    tum += b[i];
  }
  if (sum % 2 == 0 and tum % 2 == 0) {
    cout << 0;
    return;
  } else if (sum % 2 == 1 and tum % 2 == 1) {
    for (long long i = 0; i < n; i++) {
      if ((a[i] % 2 == 1 and b[i] % 2 == 0) or
          (b[i] % 2 == 1 and a[i] % 2 == 0)) {
        cout << 1;
        return;
      }
    }
    cout << -1;
  } else
    cout << -1;
}
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  solve();
  return 0;
}
