#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, a = 0, b = 0, c = 0, x, y;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    a += x;
    b += y;
    if ((x & 1) != (y & 1)) c++;
  }
  if (a % 2 == 0 && b % 2 == 0)
    cout << 0;
  else if (c % 2 == 0 && c > 0)
    cout << 1;
  else
    cout << -1;
  return 0;
}
