#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[111];
int main() {
  int n;
  int sum1 = 0, sum2 = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second;
    sum1 += a[i].first;
    sum2 += a[i].second;
  }
  if ((sum1 + sum2) % 2 != 0) {
    cout << -1 << endl;
    return 0;
  }
  if (sum1 % 2 == 0) {
    cout << 0 << endl;
    return 0;
  }
  bool h = false;
  for (int i = 0; i < n; ++i) {
    if ((a[i].first + a[i].second) % 2 != 0) h = true;
  }
  if (h == true) {
    cout << 1 << endl;
    return 0;
  }
  cout << -1 << endl;
  return 0;
}
