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