#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, t;
  cin >> n;
  vector<int> l, r;
  for (int i = 0; i < n; ++i) {
    cin >> t;
    if (t % 2 != 0)
      l.push_back(1);
    else
      l.push_back(0);
    cin >> t;
    if (t % 2 != 0)
      r.push_back(1);
    else
      r.push_back(0);
  }
  int a, b;
  a = count(l.begin(), l.end(), 1);
  b = count(r.begin(), r.end(), 1);
  if ((a + b) % 2 != 0) {
    cout << -1;
    return 0;
  }
  if (a % 2 != 0) {
    for (int i = 0; i < n; ++i) {
      if (l[i] != r[i]) {
        cout << 1;
        return 0;
      }
    }
  }
  if (b % 2 != 0) {
    for (int i = 0; i < n; ++i) {
      if (l[i] != r[i]) {
        cout << 1;
        return 0;
      }
    }
  }
  if (a % 2 == 0 && b % 2 == 0)
    cout << 0;
  else
    cout << -1;
  return 0;
}
