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