#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0, fir = 0, x = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    sum += a + b;
    fir += a;
    if (abs(a - b) % 2) ++x;
    if (n == 1) {
      if (a % 2 == 0 && b % 2 == 0)
        cout << 0 << endl;
      else
        cout << -1 << endl;
      return 0;
    }
  }
  if (sum % 2)
    cout << -1 << endl;
  else {
    if (fir % 2) {
      if (x)
        cout << 1 << endl;
      else
        cout << -1 << endl;
    } else
      cout << 0 << endl;
  }
  return 0;
}
