#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  long long int s_u = 0;
  long long int s_l = 0;
  long long int cnt = 0;
  for (long long int i = 0; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
    s_u += a;
    s_l += b;
    if ((a % 2 == 0 and b % 2 != 0) or (a % 2 != 0 and b % 2 == 0)) {
      cnt++;
    }
  }
  if (s_u % 2 == 0 and s_l % 2 == 0) {
    cout << "0"
         << "\n";
  } else if ((s_u % 2 == 0 and s_l % 2 != 0) or
             (s_u % 2 != 0 and s_l % 2 == 0)) {
    cout << "-1"
         << "\n";
  } else {
    if (cnt >= 1) {
      cout << "1"
           << "\n";
    } else {
      cout << "-1"
           << "\n";
    }
  }
  return 0;
}
