#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, l = 0, r = 0;
  cin >> n;
  bool s = false;
  for (int i = 0, x, y; i < n; i++) {
    cin >> x >> y;
    if (n == 1 && x % 2 + y % 2 == 1) {
      cout << -1;
      return;
    }
    if (x % 2 + y % 2 == 1) s = true;
    l += x;
    r += y;
  }
  if (l % 2 == 0 && r % 2 == 0)
    cout << 0;
  else if (l % 2 == 1 && r % 2 == 1 && s)
    cout << 1;
  else
    cout << -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
