#include <bits/stdc++.h>
using namespace std;
deque<int> arr[5001];
void solve() {
  int n, a, b;
  cin >> n;
  int sum1 = 0, sum2 = 0;
  int count = 0;
  while (n--) {
    cin >> a >> b;
    if ((a % 2 == 0 && b % 2 == 1) || (a % 2 == 1 && b % 2 == 0)) count++;
    sum1 += a, sum2 += b;
  }
  if (sum1 % 2 == 0 && sum2 % 2 == 0) {
    cout << 0 << endl;
  } else if (count > 0 && sum1 % 2 == 1 && sum2 % 2 == 1) {
    cout << 1 << endl;
  } else {
    cout << -1 << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
