#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, i, t1, t2, su = 0, sd = 0, flag = 0, flag1 = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> t1 >> t2;
    su += t1;
    sd += t2;
    if ((t1 + t2) % 2 != 0) flag = 1;
    if (t1 % 2 != 0 && t2 % 2 != 0) flag1 = 1;
  }
  if (su % 2 == 0 && sd % 2 == 0)
    cout << 0;
  else if (su % 2 != 0 && sd % 2 != 0 && flag == 1 && n > 1)
    cout << 1;
  else
    cout << -1;
}
