#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, j, so = 0, se = 0, diff = 0;
  cin >> n;
  long long int x[n], y[n];
  for (i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    so += x[i];
    se += y[i];
    if ((x[i] + y[i]) % 2 == 1) diff++;
  }
  if (so % 2 == 0 & se % 2 == 0)
    cout << 0;
  else if ((so + se) % 2 == 1)
    cout << -1;
  else {
    if (diff > 0)
      cout << 1;
    else
      cout << -1;
  }
  return 0;
}
