#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, a, b, cnt1 = 0, cnt2 = 0;
  bool s(false);
  cin >> t;
  for (int i = 1; i <= t; i++) {
    cin >> a >> b;
    if (t == 1 && a % 2 + b % 2 == 1) {
      cout << -1 << endl;
      return 0;
    }
    if (b % 2 + a % 2 == 1) {
      s = true;
    }
    cnt1 += a;
    cnt2 += b;
  }
  if (cnt1 % 2 == 0 && cnt2 % 2 == 0)
    cout << 0 << endl;
  else if (cnt1 % 2 == 1 && cnt2 % 2 == 1 && s)
    cout << 1 << endl;
  else
    cout << -1 << endl;
  return 0;
}
