#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[2][101], sum = 0, suml = 0, sumr = 0, i, sp = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[0][i] >> a[1][i];
    sum += a[0][i] + a[1][i];
    suml += a[0][i];
    sumr += a[1][i];
    if ((a[0][i] % 2 != 0 && a[1][i] % 2 == 0) ||
        (a[1][i] % 2 != 0 && a[0][i] % 2 == 0))
      sp++;
  }
  if (sum % 2 != 0) {
    cout << "-1";
    return 0;
  }
  if (suml % 2 == 0) {
    cout << "0";
    return 0;
  }
  if (suml != 0 && sumr != 0 && sp != 0)
    cout << "1";
  else
    cout << "-1";
  return 0;
}
