#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265359;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int a[1000], b[1000], c, d, n, k = 0, j, h = 0, i;
  string s, t;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    h = h + a[i];
    k = k + b[i];
  }
  if (h % 2 == 0 && k % 2 == 0) {
    cout << 0;
    return 0;
  } else if (h % 2 == 1 && k % 2 == 1) {
    for (i = 0; i < n; i++) {
      if (a[i] % 2 == 1 && b[i] % 2 == 0) {
        cout << 1;
        return 0;
      } else if (a[i] % 2 == 0 && b[i] % 2 == 1) {
        cout << 1;
        return 0;
      }
    }
  }
  cout << -1;
  return 0;
}
