#include <bits/stdc++.h>
using namespace std;
int x[1234];
int y[1234];
void go() {
  bool hhe = false;
  int n;
  cin >> n;
  int sum1 = 0;
  int sum2 = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a % 2 != b % 2) hhe = true;
    sum1 += a;
    sum2 += b;
  }
  if (sum1 % 2 != sum2 % 2)
    cout << -1 << endl;
  else if (sum1 % 2 == 0)
    cout << 0 << endl;
  else if (hhe)
    cout << 1 << endl;
  else
    cout << -1 << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  go();
}
