#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  int sum = 0;
  bool ok = 0;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    if (x % 2 != y % 2) {
      ok = 1;
    }
    sum += x;
    ans += y;
  }
  if (sum % 2 == 0 && 0 == ans % 2) {
    cout << 0;
    return 0;
  }
  if (sum % 2 != ans % 2) {
    cout << -1;
    return 0;
  }
  if (!ok) {
    cout << -1;
  } else
    cout << 1;
  return 0;
}
