#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k, cntj = 0, cntk = 0, cnto = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> j >> k;
    if (j % 2 == 1) cntj++;
    if (k % 2 == 1) cntk++;
    if ((j % 2 == 1 && k % 2 == 0) || (k % 2 == 1 && j % 2 == 0)) cnto++;
  }
  if (cntj % 2 == 0 && cntk % 2 == 0)
    cout << 0;
  else if ((cntj + cntk) % 2 == 0 && cnto != 0) {
    cout << 1;
  } else
    cout << -1;
  return 0;
}
