#include <bits/stdc++.h>
using namespace std;
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
template <typename T>
T POW(T B, T P) {
  if (P == 0) return 1;
  if (P & 1)
    return B * POW(B, P - 1);
  else
    return (POW(B, P / 2)) * (POW(B, P / 2));
}
long long powmod(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % 100000007;
    a = a * a % 100000007;
    b >>= 1;
  }
  return ans;
}
int main() {
  int n;
  fastio();
  cin >> n;
  vector<int> v1, v2;
  int s1 = 0, s2 = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    v1.push_back(a);
    v2.push_back(b);
    s1 += a;
    s2 += b;
  }
  if (s1 % 2 && s2 % 2 && n == 1)
    cout << -1 << '\n';
  else if (s1 % 2 == 0 && s2 % 2 == 0)
    cout << 0 << '\n';
  else if ((s1 % 2 == 0 && s2 % 2) || (s1 % 2 && s2 % 2 == 0))
    cout << -1 << '\n';
  else {
    if (s1 % 2) {
      bool flag = false;
      for (int i = 0; i < n; i++) {
        if (v1[i] & 1 && (v2[i] % 2 == 0)) {
          swap(v1[i], v2[i]);
          flag = true;
          break;
        }
      }
      if (!flag) {
        for (int i = 0; i < n; i++) {
          if (!(v1[i] & 1) && (v2[i] % 2)) {
            swap(v1[i], v2[i]);
            flag = true;
            break;
          }
        }
      }
      s1 = 0, s2 = 0;
      for (int i = 0; i < n; i++) {
        s1 += v1[i];
        s2 += v2[i];
      }
      if (s1 % 2 == 0 && s2 % 2 == 0)
        cout << 1 << '\n';
      else
        cout << -1 << '\n';
    } else {
      bool flag = false;
      for (int i = 0; i < n; i++) {
        if (v2[i] & 1 && (v1[i] % 2 == 0)) {
          swap(v1[i], v2[i]);
          flag = true;
          break;
        }
      }
      if (!flag) {
        for (int i = 0; i < n; i++) {
          if (!(v2[i] & 1) && (v1[i] % 2)) {
            swap(v2[i], v1[i]);
            flag = true;
            break;
          }
        }
      }
      s1 = 0, s2 = 0;
      for (int i = 0; i < n; i++) {
        s1 += v1[i];
        s2 += v2[i];
      }
      if (s1 % 2 == 0 && s2 % 2 == 0)
        cout << 1 << '\n';
      else
        cout << -1 << '\n';
    }
  }
}
