#include <bits/stdc++.h>
using namespace std;
int c, d, n, i, k, m, j, x, y, z, X;
string s;
char ch;
int main() {
  cin >> n;
  int a[n], b[n];
  for (i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    x += a[i];
    y += b[i];
  }
  if (x % 2 == 0 && y % 2 == 0) {
    cout << 0;
    return 0;
  }
  for (i = 0; i < n; i++) {
    x = x - a[i] + b[i];
    y = y - b[i] + a[i];
    if (x % 2 == 0 && y % 2 == 0) {
      cout << 1;
      return 0;
    }
    x = x + a[i] - b[i];
    y = y + b[i] - a[i];
  }
  cout << -1;
}
