#include <bits/stdc++.h>
using namespace std;
long long minimum(long long a[], long long n) {
  long long mn = INT_MAX, i;
  for (i = 0; i < n; i++) mn = min(mn, a[i]);
  return mn;
}
long long maximum(long long a[], long long n) {
  long long mx = INT_MIN, i;
  for (i = 0; i < n; i++) mx = max(mx, a[i]);
  return mx;
}
int main() {
  int n, i, j, cnt = 0;
  cin >> n;
  vector<int> u, l;
  int a = 0, b = 0;
  for (i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a += x, b += y;
    u.push_back(x), l.push_back(y);
  }
  if (a % 2 == 0 && b % 2 == 0) {
    cout << 0;
    return 0;
  }
  if (a & 1 && b & 1) {
    for (i = 0; i < n; i++) {
      if ((u[i] & 1 && l[i] % 2 == 0) || (u[i] % 2 == 0 && l[i] & 1)) {
        cout << 1;
        return 0;
      }
    }
    cout << -1;
  }
  if ((a & 1 && b % 2 == 0) || (a % 2 == 0 && b & 1)) {
    for (i = 0; i < n; i++) {
      if ((a - u[i] + l[i]) % 2 == 0 && (b - l[i] + u[i]) % 2 == 0) {
        cout << 1;
        return 0;
      }
    }
    cout << -1;
  }
  return 0;
}
