#include <bits/stdc++.h>
using namespace std;
int sum(int *arr, int size);
bool is_even(int n);
int main() {
  int n;
  cin >> n;
  int *left = new int[n];
  int *right = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> left[i] >> right[i];
  }
  int up = sum(left, n);
  int down = sum(right, n);
  bool u = is_even(up);
  bool d = is_even(down);
  if (u && d) {
    cout << 0;
  } else if ((u && !d) | (!u && d))
    cout << -1;
  else {
    bool r;
    bool l;
    for (int i = 0; i < n; i++) {
      r = is_even(right[i]);
      l = is_even(left[i]);
      if ((r && !l) | (!r && l)) {
        cout << 1;
        return 0;
      }
    }
    cout << -1;
  }
  return 0;
}
int sum(int *arr, int size) {
  int total = 0;
  for (int i = 0; i < size; i++) {
    total += arr[i];
  }
  return total;
}
bool is_even(int n) {
  if (n % 2 == 0)
    return true;
  else
    return false;
}
