#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, up_sum = 0, low_sum = 0, flag = 0;
  cin >> n;
  int a[2 * n + 5];
  for (int i = 0; i < 2 * n; i++) cin >> a[i];
  for (int i = 0; i < 2 * n; i += 2) {
    up_sum += a[i];
    low_sum += a[i + 1];
    if ((a[i] % 2 == 0 && a[i + 1] % 2 != 0) ||
        (a[i] % 2 != 0 && a[i + 1] % 2 == 0))
      flag = 1;
  }
  if (up_sum % 2 == 0 && low_sum % 2 == 0)
    cout << 0 << endl;
  else if ((up_sum % 2 != 0 && low_sum % 2 == 0) ||
           (up_sum % 2 == 0 && low_sum % 2 != 0))
    cout << -1 << endl;
  else if (flag)
    cout << 1 << endl;
  else
    cout << -1 << endl;
  return 0;
}
