#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 0, i, aa = 0, bb = 0;
  cin >> n;
  int a[n], b[n];
  for (i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    aa = aa + a[i];
    bb = bb + b[i];
  }
  if (aa % 2 == 1 && bb % 2 == 1) {
    for (i = 0; i < n; i++) {
      if ((a[i] + b[i]) % 2 == 1) {
        c++;
        break;
      }
    }
  }
  if (aa % 2 == 0 && bb % 2 == 0)
    cout << "0";
  else if (c == 1)
    cout << "1";
  else
    cout << "-1";
}
