#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int>> v(n);
  long long int sum1 = 0, sum2 = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
    sum1 += v[i].first;
    sum2 += v[i].second;
  }
  if (sum1 % 2 == 0 && sum2 % 2 == 0) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if ((v[i].first % 2 == 0 && v[i].second % 2 != 0) ||
        (v[i].second % 2 == 0 && v[i].first % 2 != 0)) {
      sum1 += (v[i].second - v[i].first);
      sum2 += (-v[i].second + v[i].first);
      break;
    }
  }
  if (sum1 % 2 == 0 && sum2 % 2 == 0) {
    cout << 1;
    return 0;
  }
  cout << -1;
}
