#include <bits/stdc++.h>
using namespace std;
int main() {
  int sum = 0, sum1 = 0, c = 0;
  int n, x, y, d;
  cin >> n;
  d = n;
  while (n--) {
    cin >> x;
    sum = sum + x;
    cin >> y;
    sum1 = sum1 + y;
    if (x % 2 == 0 && y % 2 == 1 || (y % 2 == 0 && x % 2 == 1)) c++;
  }
  cout << (sum % 2 == 0 && sum1 % 2 == 0
               ? 0
               : (sum % 2 == 1 && sum1 % 2 == 1 && c > 0 && d > 1 ? 1 : -1))
       << endl;
}
