#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n) {
  if (n == 1) return false;
  if (n == 2) return true;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int GCD(int a, int b) {
  if (!b) return a;
  return GCD(b, a % b);
}
int LCM(int a, int b) { return (a * b) / GCD(a, b); }
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    bool flag = 0;
    int sum1 = 0, sum2 = 0;
    while (n--) {
      int x, y;
      cin >> x >> y;
      sum1 += x;
      sum2 += y;
      if (sum1 % 2 != sum2 % 2) {
        flag = 1;
      }
    }
    if (sum1 % 2 == 0 && sum2 % 2 == 0) {
      cout << "0";
    } else if ((sum1 + sum2) % 2 != 0 || !flag) {
      cout << "-1";
    } else {
      cout << "1";
    }
  }
  return 0;
}
