#include <bits/stdc++.h>
using namespace std;
const char char_max = (char)(((unsigned char)char(-1)) / 2);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k = 0, sum1 = 0, sum2 = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    sum1 += l;
    sum2 += r;
    k += (l % 2 == 0) ^ (r % 2 == 0) ? 1 : 0;
  }
  if (sum1 % 2 == 0 && sum2 % 2 == 0)
    cout << "0"
         << "\n";
  else if (sum1 % 2 == 1 && sum2 % 2 == 1) {
    cout << (k > 0 ? 1 : -1);
  } else
    cout << "-1";
}
