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