#include <bits/stdc++.h>
using namespace std;
int a[101], b[101];
int main() {
  int n, p = 0, q = 0, z = 0, ccc, shimi9;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    p += a[i];
    q += b[i];
    if ((a[i] % 2) == (b[i] % 2)) {
      z++;
    }
  }
  if ((q + p) % 2 == 1) {
    cout << -1;
  } else {
    if (p % 2 == 0) {
      cout << 0;
    } else {
      if (z == n) {
        cout << -1;
      } else {
        cout << 1;
      }
    }
  }
  return 0;
}
