#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[2000], b[2000], ansu = 0, ansd = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if (b[i] % 2) ansu++;
    if (a[i] % 2) ansd++;
  }
  if (ansu % 2 == 0 && ansd % 2 == 0) {
    cout << 0 << endl;
    return 0;
  }
  if ((ansu + ansd) % 2) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if ((a[i] % 2 && !(b[i] % 2)) || (b[i] % 2 && !(a[i] % 2))) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
