#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > dice;
bool check() {
  int left = 0, right = 0;
  for (int i = 0; i < dice.size(); i++) {
    left += dice[i].first;
    right += dice[i].second;
  }
  return (!(left % 2) && !(right % 2));
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    dice.push_back(make_pair(x, y));
  }
  if (!check()) {
    for (int i = 0; i < n; i++) {
      if ((dice[i].first % 2 == 0 && dice[i].second % 2) ||
          (dice[i].first % 2 && dice[i].second % 2 == 0)) {
        swap(dice[i].first, dice[i].second);
        break;
      }
    }
  } else {
    cout << 0 << endl;
    return 0;
  }
  if (check())
    cout << 1 << endl;
  else
    cout << -1 << endl;
  return 0;
}
