#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, oo = 0, ee = 0, oe = 0, eo = 0, sumu = 0, sumd = 0, a[1000], b[1000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] & 1 && b[i] & 1)
      oo++;
    else if (a[i] & 1 && b[i] % 2 == 0)
      oe++;
    else if (a[i] % 2 == 0 && b[i] % 2 == 1)
      eo++;
    else
      ee++;
    sumu += a[i];
    sumd += b[i];
  }
  if (sumu % 2 == 0 && sumd % 2 == 0) {
    cout << 0 << endl;
    return 0;
  }
  if ((sumu % 2 == 1 && sumd % 2 == 0) || (sumu % 2 == 0 && sumd % 2 == 1)) {
    cout << -1 << endl;
    return 0;
  } else {
    if (oe || eo)
      cout << 1;
    else
      cout << -1;
  }
  return 0;
}
