#include <bits/stdc++.h>
using namespace std;
const int MX = 1 << 28;
int d[100], e[100];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    d[i] = a;
    e[i] = b;
  }
  bool vaihto = false;
  int yp = 0, ap = 0;
  for (int i = 0; i < n; i++) {
    if (d[i] % 2 == 1) {
      yp++;
    }
    if (e[i] % 2 == 1) {
      ap++;
    }
    if ((d[i] % 2) != (e[i] % 2)) vaihto = true;
  }
  if (yp % 2 == 0 && ap % 2 == 0)
    cout << 0 << "\n";
  else {
    if (yp % 2 == 1 && ap % 2 == 1 && vaihto)
      cout << 1 << "\n";
    else
      cout << -1 << "\n";
  }
}
