#include <bits/stdc++.h>
using namespace std;
int main() {
  int dominoes, flag_one, flag_two, flag_three = 0, upper = 0, lower = 0;
  vector<pair<int, int> > haves;
  cin >> dominoes;
  for (int i = 0; i < dominoes; i++) {
    cin >> flag_one >> flag_two;
    upper += flag_one;
    lower += flag_two;
    haves.push_back(make_pair(flag_one, flag_two));
  }
  if (lower % 2 == 0 && upper % 2 == 0)
    cout << 0 << endl;
  else if ((lower + upper) % 2 != 0)
    cout << -1 << endl;
  else {
    for (int k = 0; k < dominoes; k++) {
      if ((haves[k].first % 2 == 0 && haves[k].second % 2 != 0) ||
          (haves[k].first % 2 != 0 && haves[k].second % 2 == 0)) {
        cout << 1 << endl;
        flag_three = 1;
        break;
      }
    }
    if (flag_three == 0) cout << -1 << endl;
  }
  return 0;
}
