#include <bits/stdc++.h>
using namespace std;
void adskiy_razgon() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const int mxN = 1e+9 + 7;
const long long INF = 1e+18 + 7;
int nod(int a, int b) {
  if (a == 0 || b == 0) {
    return 0;
  } else if (a == b) {
    return a;
  } else if (a > b) {
    return nod(a - b, b);
  } else {
    return nod(a, b - a);
  }
}
int nok(int a, int b) { return a * b / nod(a, b); }
void sp(int a, double b) { cout << fixed << setprecision(a) << b; }
int a[1000], b[100];
void solve() {
  int n, cnt1 = 0, cnt2 = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i];
    cnt1 += a[i], cnt2 += b[i];
  }
  if (cnt1 % 2 == 0 && cnt2 % 2 == 0) {
    cout << 0;
    return;
  }
  int odd = 0, even = 0;
  for (int i = 1; i <= n; ++i) {
    if (a[i] % 2 == 0 && b[i] % 2 == 1) {
      even++;
    }
    if (a[i] % 2 == 1 && b[i] % 2 == 0) {
      odd++;
    }
  }
  if ((even + odd) == 0 || (even + odd) % 2 == 1) {
    cout << -1;
  } else {
    cout << 1;
  }
}
int main() {
  adskiy_razgon();
  long long t = 1;
  for (int i = (1); i < (t + 1); i++) {
    solve();
  }
  return 0;
}
